akhauriyash/Code-Regression huggingface dataset:
<?php


$v_arr = explode(' ', $v);

fscanf(STDIN, "%d", $n);
$v_arr = explode(' ', trim(fgets(STDIN)));

$odd_arr = [];
$even_arr = [];
foreach ($v_arr as $i => $v) {
    if ($i % 2 === 0) {
        $even_arr[] = $v;
    } else {
        $odd_arr[] = $v;
    }
}

// Odd
$tmp_arr = [];
foreach ($odd_arr as $odd) {
    if (!isset($tmp_arr[$odd])) {
        $tmp_arr[$odd] = 1;
    } else {
        ++$tmp_arr[$odd];
    }
}
arsort($tmp_arr);


$tmp_arr2 = [];
foreach ($even_arr as $even) {
    if (!isset($tmp_arr2[$even])) {
        $tmp_arr2[$even] = 1;
    } else {
        ++$tmp_arr2[$even];
    }
}
arsort($tmp_arr2);


$odds = array_keys($tmp_arr);
$evens = array_keys($tmp_arr2);

if ($odds[0] != $evens[0]) {
    $odd_count = count($odd_arr) - $tmp_arr[$odds[0]];
    $even_count = count($even_arr) - $tmp_arr2[$evens[0]];

    echo $odd_count + $even_count;
} else {
    if ($tmp_arr[$odds[0]] > $tmp_arr2[$evens[0]]) {
        $odd_count = count($odd_arr) - $tmp_arr[$odds[0]];
        $even_count = count($even_arr) - $tmp_arr2[$evens[1]];

        echo $odd_count + $even_count;
    } elseif ($tmp_arr[$odds[0]] < $tmp_arr2[$evens[0]]) {
        $odd_count = count($odd_arr) - $tmp_arr[$odds[1]];
        $even_count = count($even_arr) - $tmp_arr2[$evens[0]];

        echo $odd_count + $even_count;
    } else {

        if ($tmp_arr[$odds[1]] > $tmp_arr2[$evens[1]]) {
            $odd_count = count($odd_arr) - $tmp_arr[$odds[1]];
            $even_count = count($even_arr) - $tmp_arr2[$evens[0]];

echo PHP_EOL;
echo $odd_count + $even_count;
        } else {
            $odd_count = count($odd_arr) - $tmp_arr[$odds[0]];
            $even_count = count($even_arr) - $tmp_arr2[$evens[1]];

            echo $odd_count + $even_count;
        }
    }
}


Measured memory_bytes: 25076
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
typedef vector<int> vi;
typedef vector<vi> vvi;

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    int h,r;
    Edge(int a, int b, Weight c, int h, int r) :
        src(a), dst(b), weight(c), h(h), r(r){}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int const inf=1<<28;

int N,M,H,K;
int s,t;
int P;
Graph g;
int group[1<<8];
int cost[1<<8];

int dp1[1<<8];
int dp2[25][100];

int dijk(int S){
    auto dp=dp2;
    rep(i,H+1)rep(j,N)dp[i][j]=inf;
    dp[0][s]=0;
    rep(h,H+1)rep(i,N){
        each(e,g[i]){
            if(h+e.h>H)continue;
            int cost = S>>e.r&1 ? 0 : e.weight;
            dp[h+e.h][e.dst]=min(dp[h+e.h][e.dst], dp[h][e.src]+cost);
        }
    }

    // rep(i,H+1)rep(j,N){
    //     if(j==0) printf("h=%2d : ",i);
    //     printf("%10d",dp[i][j]);
    //     if(j==N-1) puts("");
    // }
    // puts("");
    int ans=inf;
    rep(h,H+1){
        ans=min(ans,dp[h][t]);
    }
    return ans;
}

int solve(){
    rep(i,1<<K)dp1[i]=inf;
    dp1[0]=0;
    rep(i,P){
        rep(S,1<<K){
            dp1[S|group[i]]=min(dp1[S|group[i]], dp1[S]+cost[i]);
        }
    }
    int ans=inf;
    rep(S,1<<K){
        ans=min(ans,dijk(S)+dp1[S]);
    }
    return ans==inf?-1:ans;
}

int main(){
    while(cin>>N && N){
        scanf("%d%d%d",&M,&H,&K);
        g.assign(N,{});
        rep(i,M){
            int a,b,c,h,r;
            scanf("%d%d%d%d%d",&a,&b,&c,&h,&r);
            a--; b--; r--;
            g[a].emplace_back(Edge(a,b,c,h,r));
            g[b].emplace_back(Edge(b,a,c,h,r));
        }
        scanf("%d%d%d",&s,&t,&P);
        s--; t--;
        memset(group,0,sizeof(group));
        rep(i,P){
            int l;
            scanf("%d%d",&l,&cost[i]);
            rep(j,l){
                int k; scanf("%d",&k);
                k--;
                group[i]|=1<<k;
            }
        }
        printf("%d\n",solve());
    }
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;
const int MAXH = 2010;
const int MAXW = 2010;

int h, w;
char s[MAXH][MAXW];
int cntRow[MAXH][MAXW];
int cntCol[MAXH][MAXW];

void solve() {
  for (int y=0;y<h;y++) {
    int cnt = 0;
    for (int x=0;x<w;x++) {
      cnt = 0;
      int tx = x;
      while (x < w && s[y][x] == '.') {
        x++;
        cnt++;
      }
      for (int i=tx;i<x;i++) {
        cntRow[y][i] = cnt;
      }
    }
  }

  for (int x=0;x<w;x++) {
    int cnt = 0;
    for (int y=0;y<h;y++) {
      cnt = 0;
      int ty = y;
      while (y < h && s[y][x] == '.') {
        y++;
        cnt++;
      }
      for (int i=ty;i<y;i++) {
        cntCol[i][x] = cnt;
      }
    }
  }
  int maxVal = 0;
  for (int y=0;y<h;y++) {
    for (int x=0;x<w;x++) {
      maxVal = max(maxVal, cntCol[y][x] + cntRow[y][x] - 1);
    }
  }
  cout << maxVal << endl;
}

int main() {
  cin >> h >> w;
  for (int y=0;y<h;y++) {
    for (int x=0;x<w;x++) {
      cin >> s[y][x];
    }
  }
  solve();
}


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

using namespace std;

int main(void)

{
    int n, i, j, m = INT_MAX, l = 0, r = 0, dif;
    cin>>n;
    int ara[n];
    for(i = 0; i < n; i++)
        cin>>ara[i];
    for(i = 1; i < n; i++){
        for(j = 0; j < i; j++){
            l += ara[j];
        }
        for(j = i; j < n; j++){
            r += ara[j];
        }
        dif = abs(l-r);
        if(dif < m)
            m = dif;
        l = 0;
        r = 0;
    }
    cout<<m<<"\n";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n;
    int a,b,min1=0,min2;
    cin >> n;
    rep(i, n) {
        cin >> a >> b;
        if (a > min1) {
            min1 = a, min2 = b;
        }
    }
    int cnt = min1 + min2;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      
      // カウント
      int count = 0;
      for(long A = 1L; A < N; A++){
        for(long B = 1L; B <= A; B++){
          if(A*B < N){
            if(A != B){
              count += 2;
            }else{
              count++;
            }
          }else{
            break;
          }
        }
      }
      
      // 出力
      System.out.println(count);
    }
    
}

Measured memory_bytes: 35768
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n,k;cin>>n>>k;
    vector<int> v[n+1];
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    if(k%2==0){
        int d[n+1][n];
        rep(i,0,n+1)fill(d[i],d[i]+n,0);
        rep(i,1,n+1){
            bool used[n+1];
            fill(used,used+n+1,false);
            int dis[n+1];
            dis[i]=0;
            queue<int> q;
            q.push(i);
            used[i]=true;
            while(q.size()>0){
                int now=q.front();q.pop();
                d[i][dis[now]]++;
                rep(j,0,v[now].size()){
                    int ne=v[now][j];
                    if(used[ne])continue;
                    used[ne]=true;
                    q.push(ne);
                    dis[ne]=dis[now]+1;
                }
            }
        }
        int ans=0;
        rep(i,1,n+1){
            int sum=0;
            rep(j,0,k/2+1){
                sum+=d[i][j];
            }
            ans=max(ans,sum);
        }
        cout<<n-ans<<endl;
    }
    else{
        int par[n+1];
        par[1]=0;
        queue<int> qq;
        qq.push(1);
        while(qq.size()){
            int now=qq.front();qq.pop();
            rep(i,0,v[now].size()){
                int ne=v[now][i];
                if(ne==par[now])continue;
                par[ne]=now;
                qq.push(ne);
                
            }
        }
        int d[n+1][n];
        rep(i,0,n+1)fill(d[i],d[i]+n,0);
        rep(i,2,n+1){
            bool used[n+1];
            fill(used,used+n+1,false);
            int dis[n+1];
            dis[i]=0;
            dis[par[i]]=0;
            queue<int> q;
            q.push(i);
            q.push(par[i]);
            used[i]=true;
            used[par[i]]=true;
            while(q.size()>0){
                int now=q.front();q.pop();
                d[i][dis[now]]++;
                rep(j,0,v[now].size()){
                    int ne=v[now][j];
                    if(used[ne])continue;
                    used[ne]=true;
                    q.push(ne);
                    dis[ne]=dis[now]+1;
                }
            }
        }
        int ans=0;
        rep(i,2,n+1){
            int sum=0;
            rep(j,0,k/2+1){
                sum+=d[i][j];
            }
            ans=max(ans,sum);
        }
        cout<<n-ans<<endl;
    }
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define fore(i,a,b) for(Long i=a,to=b;i<to;i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long Long;
typedef long double Double;
const Long MX=(2e6);
Long fact[MX+2];
Long invFact[MX+2];
const Long MOD=(1e9+7);
Long C(Long x,Long y){
	Long ans = fact[x];
	ans *= invFact[y];
	ans %= MOD;
	ans *= invFact[x-y];
	ans %= MOD;
	return ans;
}
Long pot(Long x,Long y){
	Long ans = 1LL;
	Long a = x;
	while(y){
		if(y%2==1)ans=(ans*a)%MOD;
		a = (a*a)%MOD;
		y/=2;
	}
	return ans;
}
Long inv(Long x){
	//cout<<x<<" "<<pot(x,MOD-2)<<endl;
	return pot(x,MOD-2);
}
void init(){
	fact[0] = 1LL;
	invFact[0] = 1LL;
	fore(i,1,MX+1){
		fact[i] = (fact[i-1]*i)%MOD;
		invFact[i] = (invFact[i-1]*inv(i))%MOD;
	}
}
int main() {
	// your code goes here
	init();
	Long x,y;cin>>x>>y;
	if((2*x-y)%3!=0){
		cout<<0<<endl;
		return 0;
	}
	Long a = (2*x-y)/3;
	Long b = (2*y-x)/3;
  	if(a<0 || b<0)cout<<0<<endl;
	else cout<<C(a+b,a)<<endl;
	//cout<<C(4,2)<<endl;

	return 0;
}

Measured memory_bytes: 31488
# coding: UTF-8
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
tile = [a1, a2]
x, y = 0, 0
score = 0

def move(i, x, y):
    score = tile[y][x]
    for j in range(i):
        x, y = right(x, y)
        score += tile[y][x]
    x, y = under(x, y)
    score += tile[y][x]
    for j in range(n-i-1):
        x, y = right(x, y)
        score += tile[y][x]
    return(score)

def right(x, y):
    if(x < n-1):
        return(x+1, y)
    else:
        return(x, y)

def under(x, y):
    if(y < 1):
        return(x, y+1)
    else:
        return(x, y)

for i in range(n):
    now_score = move(i, 0, 0)
    if(score < now_score):
        score = move(i, 0, 0)

print(score)

Measured memory_bytes: 3064
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
// #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;


int main(){
  int n,k = 0;
  int ans = 1;
  cin  >> n >> k;
  while(n >= k){
    n /= k;
    ans +=1;
  }
  cout << ans; 
}



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

using namespace std;

int main()
{
    int p, q, r;
    cin>> p >> q >> r;
    int res = 300000;
    int a[3];
    a[0] = p, a[1] = q, a[2] = r;
    sort(a, a + 3);
    res = min(res, a[0] + a[1]);
    
    cout<< res << endl;
    
    return 0;
}

Measured memory_bytes: 256
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: i32 = read();
    let an: Vec<i32> = read_vec();
    let mut result: Vec<i32> = Vec::with_capacity(n as usize);

    for i in 0..n
    {
        result.push(0);
    }

    for i in 0..n
    {
        result[(an[i as usize] - 1) as usize] = i + 1;
    }

    for i in 0..n
    {
        print!("{}", result[i as usize]);
        if i < n - 1 { print!(" "); }
    }

    println!("");
}


Measured memory_bytes: 4860
#include <iostream>
#include <cstddef>
#include <string>
using ll = long long;

ll n;
std::string s, s2;
char t[4];
char p;
ll ans;

int main() {
    std::cin >> n;
    std::cin >> s;
    for (int i = 0; i < 1000; i++) {
        bool torf = true;
        std::snprintf(t, 4, "%03d", i);
        s2 = t;
        long long int pos = -1;
        for (int j = 0; j < 3; j++) {
            pos = s.find(s2[j], pos+1);
            if (pos == std::string::npos) {
                torf = false;
                break;
            }
        }
        if (torf)
            ans++;
    }
    std::cout << ans << std::endl;
}

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

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



vector<int> P;
void make_primes(int n)
{
	vector<bool> primes;

	primes.resize(n + 1, true);
	primes[0] = primes[1] = false;
	rep(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) < n; j++)
		primes[i * (j + 2)] = false;

	rep(i, 2, n + 1) if (primes[i]) P.push_back(i);
}
int n;
int m;

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n>>m;
    int ans=0;
    rep(i,1,sqrt(m+1)){
        if(m%i)continue;
        int x=i;
        int y=m/i;
        if(y*n<=m)ans=max(ans,y);
        if(x*n<=m)ans=max(ans,x);
    }
    
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
//#include<vector>
//#include<math.h>
//#include<unordered_map>
using namespace std;

int A[100000];
int B[100000];

int main (void) {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
    B[A[i]] = i;
  }
  
  for (int i = 0; i < N; i++) {
    cout << B[i]+1 << " ";
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (ll i=(a); i<(b);++i)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<ll,ll> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a,k) sort(a,a+k,greater<ll>())
#define rsrt(a) sort(a.begin(),a.end(),greater<ll>())
#define sz(a) (ll)a.size()
//#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define setbits(a) __builtin_popcount(a)
const ll M=1e9+7;
const ll MX=1e6+1;

int main()
{  
    //   #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

  int tt=1;
  //cin>>tt;
  while(tt--)
  {
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll div=x/d;
    if(div>=k)cout<<x-k*d;
    else
    {
       x-=div*d;
       k-=div;
       if(k%2==0)cout<<x;
       else cout<<abs(x-d);
    }
  }
}



Measured memory_bytes: 3540
main :: IO ()
main = do
  a <- readLn :: IO Int
  b <- readLn :: IO Int
  c <- readLn :: IO Int
  d <- readLn :: IO Int
  e <- readLn :: IO Int
  k <- readLn :: IO Int
  
  putStrLn $ if and [(b-a)<=k
                    ,(c-a)<=k
                    ,(d-a)<=k
                    ,(e-a)<=k
                    ,(c-b)<=k
                    ,(d-b)<=k
                    ,(e-b)<=k
                    ,(d-c)<=k
                    ,(e-c)<=k
                    ,(e-d)<=k]
             then "Yay!"
             else ":("


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x; cin>>x;
	int cur=0;
	for (int i=1; i<=1e6; i++) {
		cur+=i;
		if(x<=cur) {
			cout<<i<<"\n";
			return 0;
		}
	}
	return 0;
}

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

#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=b-1;i>=a;i--)

auto clk=clock();
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());


const ll N=1e5+5;
vector<ll>adj[N];
ll n,in[N],out[N],M;

void dfs(ll v,ll pv)
{
  ll res=1;
  for(auto i:adj[v])
  {
    if(i==pv) continue;
    dfs(i,v);
    res=(res*(1+in[i]))%M;
  }
  
  in[v]=res;
}



void dfs2(ll v,ll pv)
{
  ll chCnt=adj[v].size()-1;
  if(v==1) chCnt++;
  
  if(!chCnt) return;

  ll pre[chCnt+3],pos[chCnt+3];
  
  f(i,0,chCnt+3) pre[i]=pos[i]=1;
  
  ll j=0;
  for(auto i:adj[v])
  {
    if(i==pv) continue;
    j++;
    pre[j]=(pre[j-1]*(in[i]+1))%M;
  }
  
  j=chCnt+1;
  fi(i,0,(ll)adj[v].size())
  {
    if(adj[v][i]==pv) continue;
    j--;
    pos[j]=(pos[j+1]*(in[adj[v][i]]+1))%M;
  }
 
  
  j=0;
  ll res=1;
  for(auto i:adj[v])
  {
    if(i==pv) continue;
    j++;
    res=(pre[j-1]*pos[j+1])%M;
    res=(res*(out[v]))%M;
    res=(res+1)%M;
    out[i]=res;
    dfs2(i,v);
  }
  
  
}

int main()
{
  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  cout<<fixed<<setprecision(8);
  
  cin>>n>>M;
  
  ll u,v;
  f(i,0,n-1) 
  {
    cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  
  dfs(1,0);
  out[1]=1;
  dfs2(1,0);
  
  ll ans;
  f(i,1,n+1) 
  {
    ans=(in[i]*out[i])%M;
    cout<<ans<<"\n";
  }
  
  
  #ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
  #endif
    
  return 0;
}

Measured memory_bytes: 23376
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

struct edge {
    int v;
    ll w;
    edge() {}
    edge(int v, ll w) : v(v), w(w) {};
};

vector<ll> dijkstra(int n, vector<vector<edge> >& G, int s) {
    vector<ll> d(n, LLONG_MAX/10); d[s] = 0;
    priority_queue<pair<ll, int> > que;
    que.push(make_pair(0ll, s));
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int u = p.second;
        ll dist = -p.first;
        if (dist > d[u]) continue;
        for (edge e : G[u]) {
            if (d[e.v] > d[u]+e.w) {
                d[e.v] = d[u] + e.w;
                que.push(make_pair(-d[e.v], e.v));
            }
        }
    }
    return d;
}


const int MAXN = 2222;
int A[MAXN], B[MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<vector<edge> > G(N);
	for (int i = 0; i < N - 1; i++) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		G[A[i]].emplace_back(B[i], 1);
		G[B[i]].emplace_back(A[i], 1);
	}
	int ans = N;
	if (K % 2 == 0) {
		for (int i = 0; i < N; i++) {
			auto d = dijkstra(N, G, i);
			int cnt = 0;
			for (int j = 0; j < N; j++) {
				if (d[j] > K / 2) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	else {
		for (int i = 0; i < N - 1; i++) {
			auto da = dijkstra(N, G, A[i]);
			auto db = dijkstra(N, G, B[i]);
			int cnt = 0;
			for (int j = 0; j < N; j++) {
				if (min(da[j], db[j]) > (K - 1) / 2) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << endl;
    return 0;
}


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

#define int long long

struct Combination
{
  int mod;
  vector<int> mfact;
  vector<int> rfact;

  /*
    constructor : O(sz+log(mod))    
   */
  Combination(int sz, int mod) : mfact(sz+1), rfact(sz+1), mod(mod) {
    mfact[0] = 1;
    for ( int i = 1; i < (int)mfact.size(); i++ ) {
      mfact[i] = mfact[i-1]*i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      rfact[i] = rfact[i+1]*(i+1) % mod;
    }
  }

  int fact(int k) const {
    return (mfact[k]);
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int inv(int x) const {
    return (pow(x, mod - 2));
  }

  /*
    permutation
   */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return (mfact[n]*rfact[n-r] % mod);
  }

  /*
    combination
   */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return (mfact[n]*rfact[r]%mod * rfact[n-r] % mod);    
  }  

  /*
    combination with repetition
   */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return 0;
    if ( n == 0 && r == 0 ) return 1;
    return C(n+r-1, n);    
  }

  /*
    stirling number
   */
  int S(int n, int r) const {
    int ret;
    for ( int i = 1; i <= r; i++ ) {
      
    }
  }

  /*
    bell number
   */
  int B(int n, int r) const {

  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  cin >> n >> k;

  int MOD = 1e9+7;  
  Combination c(2000, MOD);
  cout << c.C(k, n) << endl;  
  
  return 0;
}



Measured memory_bytes: 3252
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
#define int long long

ll mod_pow(ll x, ll n, ll m) {
    if(n == 0) return 1;
    ll res = mod_pow(x * x % m, n / 2, m);
    if(n & 1) res = res * x % m;
    return res;
}

int n, x, y, z;
//余事象を考える！！　<- 直接考えるには重複とかあってだるそう　<- 見つけたものが、x, y, zとなる箇所が１箇所とは限らない
//余事象の方が考えやすい
//情報をどうもつか？？
//前から順に決めていく
//前16個の値がわかればok -> 流石に多すぎ　-> 直前に現れた合計が16以下となるような範囲まで前の情報を持っておけばok

ll dp[50][1000100];
int ng = 0;

ll rec(int i, int bit) {
	if(i == n) return 1;
	if(dp[i][bit] != -1) return dp[i][bit];
	int res = 0;
	for(int j = 1; j <= 10; ++j) {
		int tmp = (bit << j) + (1LL<<j);
		tmp &= (1LL<< 18) - 1;
		if((tmp & ng) == ng) continue;
		res += rec(i + 1, tmp);
		res %= mod;
	}
	return dp[i][bit] = res;
}

void solve() {
	cin >> n >> x >> y >> z;
    memset(dp, -1, sizeof(dp));
	ng = (1LL<<(x + y + z)) + (1LL<<(y + z)) + (1LL<<z);
	cout << ((mod_pow(10, n, mod) - rec(0, 0) + mod) % mod) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 390912
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=1e5+70;
struct node
{
	int to,next,c;
}e[N*2];
int first[N];int visit[N];
int cnt=0;
void insert(int u,int v,int c)
{
	e[++cnt]=(node){v,first[u],c};first[u]=cnt;
	e[++cnt]=(node){u,first[v],c};first[v]=cnt;
}
int fa[N][30];int dep[N];
long long dis[N];
void dfs(int x)
{
	visit[x]=1;
	for(int i=1;(1<<i)<=dep[x];i++)
		fa[x][i]=fa[fa[x][i-1]][i-1];
	for(int k=first[x];k;k=e[k].next)
	if(!visit[e[k].to])
	{
		dep[e[k].to]=dep[x]+1;
		fa[e[k].to][0]=x;
		dis[e[k].to]=dis[x]+e[k].c;
		dfs(e[k].to);
	}
}
int lca(int x,int y)
{
	if(dep[x]<dep[y])		std::swap(x,y);
	int t=dep[x]-dep[y];
	for(int i=0;(1<<i)<=t;i++)
	if(t&(1<<i))		x=fa[x][i];
	for(int i=25;i>=0;i--)
	if(fa[x][i]!=fa[y][i]&&(1<<i)<=dep[x])	 x=fa[x][i],y=fa[y][i];
	if(x==y)	return x;
	return fa[x][0];
}
int main()
{
	int n;
	scanf("%d",&n);
	int u,v,c;
	for(int i=1;i<n;i++)
	{
		scanf("%d %d %d",&u,&v,&c);
		insert(u,v,c);
	}
	dfs(1);
	int m;int k;
	scanf("%d",&m);
	scanf("%d",&k);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		int lc=lca(x,k);
		long long ans=dis[x]+dis[k]-2*dis[lc];
		lc=lca(y,k);
		ans+=dis[y]+dis[k]-2*dis[lc];
		printf("%lld\n",ans);
	}
	return 0;
}

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

int main(){
    char b;
    cin >> b;

    if(b == 'A')
        cout << "T" << endl;
    else if(b == 'C')
        cout << "G" << endl;
    else if(b == 'G')
        cout << "C" << endl;
    else
        cout << "A" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N, A, B; cin >> N >> A >> B;
  auto ans = std::min(A*N, B);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
s = 0
for i in range(len(a)):
  s += b[a[i]-1]
  if i == (len(a)-1): break
  elif (a[i+1] - a[i]) == 1:
      s += c[a[i]-1]
      
print(s)

Measured memory_bytes: 3064
MOD = 10 ** 9 + 7
n = gets.to_i
takahashi = gets.split.map(&:to_i)
aoki = gets.split.map(&:to_i)
fixed = Array.new(n)

takahashi_prev = 0
takahashi.each_with_index do |h, i|
  next if h <= takahashi_prev
  takahashi_prev = h
  fixed[i] = h
end

aoki_prev = 0
aoki.reverse.each_with_index do |h, i|
  if fixed[-i - 1] && fixed[-i - 1] > h
    puts 0
    exit
  end
  next if h <= aoki_prev
  aoki_prev = h
  fixed[-i - 1] = h
end

ans = 1
fixed.each_with_index do |h, i|
  ans *= [takahashi[i], aoki[i]].min unless h
  ans %= MOD
end

puts ans


Measured memory_bytes: 21012
import java.util.*;

public class Main{
    
    public static final int MAX = 3501;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        
        for(long x=2; x<MAX; x+=2){
            for(long y=x; y<MAX; y+=2){
                long u = n*x*y;
                long d = 4L*x*y-n*x-n*y;
                if(d!=0 && u%d==0 && u/d>0){
                    long z = u/d;
                    System.out.println(x+" "+y+" "+z);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x[5];
    int sum = 0;
    rep(i, 0, 5) cin >> x[i];
    rep(i, 0, 5) sum += x[i];

    int y[5] = {};
    rep(i, 0, 5) {
        y[i] = x[i];
        while(y[i] % 10 != 0) y[i]++;
    }

    int diff[5] = {};
    rep(i, 0, 5) diff[i] = abs(x[i] - y[i]);
    sort(diff, diff + 5);
    int ans = sum;
    rep(i, 0, 4) ans += diff[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
function stoneRemove(){
   yx.forEach(function(v,i){
      if(v[0]==v[1] && v[1]==v[2] && v[2]==v[3]&& v[3]==v[4])point+=v[0]*5;
      else if(v[0]==v[1] && v[1]==v[2] && v[2]==v[3])point+=v[0]*4;
      else if(v[1]==v[2] && v[2]==v[3] && v[3]==v[4])point+=v[1]*4;
      else if(v[0]==v[1] && v[1]==v[2])point+=v[0]*3;
      else if(v[1]==v[2] && v[2]==v[3])point+=v[1]*3;
      else if(v[2]==v[3] && v[3]==v[4])point+=v[2]*3;
      var str=v.join("").replace(/([1-9])\1{2,}/,function(x){
         return x.replace(/./g,"0");
      });
      yx[i]=str.split("").map(Number);
   });
   var flag=true;
   while(flag){
      flag=false;
      for(var i=0;i<H-1;i++){
         for(var j=0;j<5;j++){
            if(yx[i][j]!=0 && yx[i+1][j]==0){
               yx[i+1][j]=yx[i][j];
               yx[i][j]=0;
               flag=true;
            }
         }
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=(input.trim()).split("\n");
while(true){
   var h=arr.shift()-0;
   if(h==0)break;
   var H=h;
   var yx=[];
   while(h--)yx.push(arr.shift().split(" ").map(Number));
   var point=0;
   var p=point;
   while(true){
      stoneRemove();
      if(p==point)break;
      p=point;
   }
   console.log(point);
}

Measured memory_bytes: 22636
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll ans;
  rep(i, N) {
    ll a;
    cin >> a;
    if (i % 2 == 0) {
      ans.pb(a);
    } else {
      ans.insert(ans.begin(), a);
    }
  }
  if (N % 2 == 1) {
    REVERSE(ans);
  }

  rep(i, N) {
    if (i == 0) {
      cout << ans[i];
    } else {
      cout << " " << ans[i];
    }
  }
  ENDL;
  return 0;
}

Measured memory_bytes: 5288
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

bool graph[50][50]={false};
bool reached[50];
ll n,m,ans=0;

void dfs(ll pre){
  reached[pre]=true;
  rep(i,m){
    if(!graph[pre][i]) continue;
    if(reached[i]) continue;
    reached[i]=true;
    dfs(i);
  }
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  cin>>n>>m;
  vector<ll> a(m),b(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  rep(i,m){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    rep(j,n) reached[j]=false;
    dfs(0);
    bool flag=false;
    rep(j,n) if(!(reached[j])) flag=true;
    if(flag) ans++;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string ans = "";
    while (n > 0)
    {
        if (n % 26 == 0)
        {
            ans += 'z';
            n /= 26;
            n--;
        }
        else
        {
            ans += ('a' - 1 + n % 26);
            n /= 26;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int L = sc.nextInt();
      
      // 体積最大値算出
      BigDecimal bdL = BigDecimal.valueOf(L);
      BigDecimal three = BigDecimal.valueOf(3);
      BigDecimal ave = bdL.divide(three, 6, BigDecimal.ROUND_HALF_UP);
      BigDecimal max = ave;
      max = max.multiply(ave);
      max = max.multiply(ave);
      
      // 出力
      System.out.println(max);
    }
    
}

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

class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var L = new int[M];
        var R = new int[M];
        var D = new int[M];
        for (int i = 0; i < M; i++)
        {
            var LRD = ReadLine().Split().Select(int.Parse).ToArray();
            L[i] = LRD[0] - 1;
            R[i] = LRD[1] - 1;
            D[i] = LRD[2];
        }
        var uf = new WeightedUnionFind(N);
        for (int i = 0; i < M; i++)
        {
            if (uf.Same(L[i], R[i]))
            {
                if (D[i] != uf.Diff(L[i], R[i]))
                {
                    WriteLine("No");
                    return;
                }
            }
            else
            {
                uf.Unite(L[i], R[i], D[i]);
            }
        }
        WriteLine("Yes");
    }
}

class WeightedUnionFind
{
    int[] parent;
    int[] rank;
    int[] weightDiff;

    public WeightedUnionFind(int size)
    {
        var b = new int[size];
        for (int i = 0; i < b.Length; i++)
        {
            b[i] = i;
        }
        parent = b;
        rank = new int[size];
        weightDiff = new int[size];
    }

    int Root(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        else
        {
            var r = Root(parent[x]);
            weightDiff[x] += weightDiff[parent[x]];
            return parent[x] = r;
        }
    }

    int Weight(int x)
    {
        Root(x);
        return weightDiff[x];
    }

    public int Diff(int x, int y) => Weight(y) - Weight(x);

    public bool Same(int x, int y) => Root(x) == Root(y);

    public void Unite(int x, int y, int w)
    {
        w += Weight(x) - Weight(y);
        x = Root(x);
        y = Root(y);
        if (x == y) return;
        if (rank[x] < rank[y])
        {
            parent[x] = y;
            weightDiff[x] = -w;
        }
        else
        {
            parent[y] = x;
            weightDiff[y] = w;

            if (rank[x] == rank[y]) rank[x]++;
        }
    }
}

Measured memory_bytes: 20500
import sys
readline = sys.stdin.readline

Q = int(readline())

# 10 ** 5までの「2017に似た数」を全て求めておく

fact = [True] * (10 ** 5 + 1)
fact[0] = False
fact[1] = False
like2017 = [0] * (10 ** 5 + 1)
for i in range(2, len(fact)):
  if fact[i]:
    if i % 2 == 1 and fact[(i + 1) // 2]:
      like2017[i] = 1
    for j in range(i * 2, len(fact), i):
      fact[j] = False
        
for i in range(1, len(like2017)):
  like2017[i] += like2017[i - 1]

for i in range(Q):
  l,r = map(int,readline().split())
  print(like2017[r] - like2017[l - 1])


Measured memory_bytes: 12540
#include<iostream>
using namespace std;
int main()
{
   long long  int a,b,k;
    cin>>a>>b>>k;
 if(a>k)
 {
    a=a-k;
    cout<<a<<" "<<b;

 }
 else 
 {
    cout<<"0"<<" ";
    k=k-a;
    if(b>k)
    {
       cout<<b-k<<" ";
    }
    else
        cout<<"0"<<" ";
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	double maxper = 0;
	int maxa, maxb;
	for (int i = 0; 100*A*i <= F; i++) {
		for (int j = 0; 100*A*i + 100*B*j <= F; j++) {
			for (int k = 0; 100*A*i + 100*B*j + C*k <= F && C*k <= (A*i + B*j)*E; k++) {
				for (int l = 0; 100*A*i + 100*B*j + C*k + D*l <= F && C*k + D*l <= (A*i + B*j)*E; l++) {
					int a = 100*A*i + 100*B*j;
					int b = C*k + D*l;
					if (maxper <= (double)b / (double)(a + b)) {
						maxper = (double)b / (double)(a + b);
						maxa = a; maxb = b;
					}
					//cout << i << " " << j << " " << k << " " << l << endl;
				}
			}
		}
	}
	cout << maxa + maxb << " " << maxb << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int s;
    double w,h,BMI;
    while(scanf("%d,%lf,%lf",&s,&w,&h)!=EOF){
        BMI=w/h/h;
        if(BMI>=25)
        printf("%d\n",s);
    }
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  for (auto i = 0; i < k; ++i) {
    cin >> l[i] >> r[i];
    r[i]++;
  }
  const int mod = 998244353;
  vector<int> acc(n + 1), dp(n + 1);
  dp[1] = acc[1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      dp[i] += acc[max(0, i - l[j])];
      if (i >= r[j]) dp[i] -= acc[i - r[j]];
      if (dp[i] < 0) dp[i] += mod;
      if (dp[i] >= mod) dp[i] -= mod;
    }
    acc[i] = acc[i - 1] + dp[i];
    if (acc[i] >= mod) acc[i] -= mod;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 4844
#include<stdio.h>
int main()
{
	int m,n;
	while(scanf("%d%d",&n,&m),n)
	{
		bool isLose[1000] = {false};
		int i = 0, loseCount = 0, count = 0;
		while(loseCount<n-1)
		{
			if(!isLose[i])
			{
				if(++count==m)
					isLose[i]=true, count=0,++loseCount;
			}
			i = (i+1)%n;
		}
		for(i=0;i<n;i++)
			if(!isLose[i])
				printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  int res=0;
  rep(i,n){
    int buf;cin>>buf;
    while(buf%2==0){
      ++res;buf/=2;
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3600
N, Q = [int(i) for i in input().split()]
G = [[] for _ in range(N)]
counter = [0] * N
res = [0] * N
visited = [0] * N

for _ in range(N-1):
    a, b = [int(i)-1 for i in input().split()]
    G[a].append(b)
    G[b].append(a)

for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    p -= 1
    counter[p] += x

# def dfs(G, v, p):
#     visited[v] = 1
#     res[v] = res[p]+counter[v]
#     for nv in G[v]:
#         if visited[nv]: continue
#         dfs(G, nv, v)

stack = [0]
parent = [0]
while stack:
    v = stack.pop()
    p = parent.pop()
    visited[v] = 1
    res[v] = res[p]+counter[v]
    for nv in G[v]:
        if visited[nv]: continue
        stack.append(nv)
        parent.append(v)

# dfs(G, 0, 0)
print(*res)


Measured memory_bytes: 62636
s=input()
if s.count("R")==1:
    print(1)
elif s.count("R")==3:
    print(3)
elif s.count("R")==2:
    if (s[0]=="R" and s[1]=="R") or (s[1]=="R" and s[2]=="R"):
        print(2)
    else:
        print(1)
else:
    print(0)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll a[300001];
int main(){
    int n;
    cin>>n;
    rep(i,3*n) cin>>a[i];
    sort(a,a+3*n);
    ll sum=0;
    for(int i=n;i<3*n;i+=2){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2560