akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#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<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;
void solve() {
    ll ans=6;
    int a,b;cin>>a>>b;
    ans-=(a+b);
    print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define name(x) #x
using namespace std;


const int INF = INT_MAX;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}




const int MAX_SIZE = 51;
ll memo[MAX_SIZE][MAX_SIZE][61];
ll N, K;
VV(ll) A;


VV(ll) matrix_product(VV(ll) &mat, int n){
    VV(ll) out(N+1,vector<ll>(N+1,0));
    for(auto i = 1; i<=N; i++){
        for(auto j = 1; j<=N; j++){
            for(auto k = 1; k<=N; k++){
                out[i][j] += mat[i][k]*memo[k][j][n];
                out[i][j] %= MOD;
            }
        }
    }
    return out;
}

int main() {
    
    cin >> N >> K;
    A.resize(N+1);
    for(auto i = 1; i<=N; i++){
        A[i].resize(N+1);
        for(auto j = 1; j<=N; j++){
            cin >> A[i][j];
        }
    }
    
    for(auto i = 1; i<=N; i++){
        for(auto j = 1; j<=N; j++){
            memo[i][j][0] = (A[i][j]==1);
        }
    }
    
    for(auto n = 1; n<=60; n++){
        for(auto i = 1; i<=N; i++){
            for(auto j = 1; j<=N; j++){
                for(auto k = 1; k<=N; k++){
                    memo[i][j][n] += (memo[i][k][n-1]*memo[k][j][n-1])%MOD;
                    memo[i][j][n] %=MOD;
                }
            }
        }
    }
    
//    for(auto i = 1; i<=N; i++){
//        for(auto j = 1; j<=N; j++){
//            cout << memo[i][j][1] << " ";
//        }
//        cout << endl;
//    }
    
    VV(ll) mat(N+1, vector<ll>(N+1,0));
    for(auto i = 1; i<=N; i++){
        mat[i][i] = 1;
    }

    for(auto n = 0; n<=60; n++){
        if ((K>>n)%2 == 1){
            mat = matrix_product(mat,n);
        }
    }
    
    ll ans = 0;
    
    for(auto i = 1; i<=N; i++){
        for(auto j = 1; j<=N; j++){
            ans += mat[i][j];
            ans %=MOD;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 1536
/* ***************************************************
 *	Author        :mutinner
 *	Created Time  :Sat 01 Sep 2018 09:23:51 PM CST
 *	File Name     :21:23:51.cpp
 *************************************************** */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	ll n, k;
	while ( cin >> n >> k ) {
		if ( k & 1 ) {
			ll x = n / k;
			cout << x * x * x << endl;
		} else {
			ll x = ( n + k / 2 ) / k;
			ll y = n / k;
			cout << x * x * x + y * y * y << endl;
		}
	}
	return 0;
}


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

int main() {
  int N;
  cin >>N;
  vector<int> H(N);
  rep(i, N) cin >> H[i];
  int sum = 1;
  for(int i=1;i<N;i++){
    bool flag = true;
    for(int j=0;j<i;j++){
      if (H[j]>H[i]) flag = false;
    }
    if (flag){
    sum++;
    }
  }
  
  cout << sum << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
        using namespace std;
        int main(){
          int N;
          cin>>N;
          vector<int>arr(N);
          for(int i = 0; i < N; i++){
          	cin>>arr[i];
          }
          int ans = 0;
          for(int i = 0; i < N; i++){
          	int temp;
            cin>>temp;
            ans+=temp;
          }
          vector<int>Barr(N);
          for(int i =0; i < N-1; i++){
          	cin>>Barr[i];
          }
          for(int i = 0; i < N-1; i++){
          	if(arr[i] == arr[i+1]-1){
            	ans+=(Barr[arr[i]-1]);
            }
            
          }
          cout<<ans<<"\n";
          return 0;
        }

Measured memory_bytes: 256
<?php

while (true) {
    fscanf(STDIN, '%d', $x);
    fscanf(STDIN, '%d', $h);
    if ($x === 0 && $h === 0) {
        break;
    }

    $S = $x * sqrt(4 * pow($h, 2) + pow($x, 2)) + pow($x, 2);
    printf("%f\n", $S);
}

Measured memory_bytes: 6560
h,w= map(int, input().split())
a = input()

ans = 0
for i in range(h-1):
    a = a+ input()

from collections import Counter

c = Counter(a)

cm = c.most_common()


if h*w%2==1:
    cnt_odd = 0
    cnt_2 =0
    limit_2 = h//2 + w//2

    for k,v in cm:
        if v%2==1:
            cnt_odd+=1
            if cnt_odd >1:
                print('No')
                exit()
        elif v%4!=0:
            cnt_2+=1
            if cnt_2 >limit_2:
                print('No')
                exit()
    if cnt_odd == 0:
        print('No')
    else:
        print('Yes')

else:
    cnt_odd = 0
    cnt_2 =0
    if h%2!=0:
        limit_2 = w//2
    elif w%2!=0:
        limit_2 = h//2
    else:
        limit_2 = 0

    for k,v in cm:
        if v%2==1:
            cnt_odd+=1
            if cnt_odd >0:
                print('No')
                exit()
        elif v%4!=0:
            cnt_2+=1
            if cnt_2 >limit_2:
                print('No')
                exit()
    print('Yes')


Measured memory_bytes: 3316
n, m, x = map(int, input().split())
a = map(int, input().split())
to_0, to_n = 0, 0

for i in a:
    for j in range(x):
        if i == j:
            to_0 += 1

    for k in range(x, n):
        if i == k:
            to_n += 1

if to_0 >= to_n:
    print(to_n)
else:
    print(to_0)

Measured memory_bytes: 3060
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Apr 25 08:34:24 2018
//
package main

import (
	"fmt"
	"strings"
)

var S string

func main() {
	fmt.Scan(&S)

	for i := 0; i < 1<<4; i++ {
		str := []string{""}
		if i&(1<<0) != 0 {
			str = append(str, "A")
		}
		str = append(str, "KIH")
		if i&(1<<1) != 0 {
			str = append(str, "A")

		}
		str = append(str, "B")
		if i&(1<<2) != 0 {
			str = append(str, "A")

		}
		str = append(str, "R")
		if i&(1<<3) != 0 {
			str = append(str, "A")
		}
		if strings.Join(str, "") == S {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      a: usize,
      b: usize,
      ps: [usize; n],
    }

    let mut aa = 0;
    let mut bb = 0;
    let mut cc = 0;

    for &p in ps.iter() {
        if p <= a {
            aa += 1;
        }
        else if p <= b {
            bb += 1;
        } else {
            cc += 1;
        }
    }
    println!("{}", min(aa, min(bb, cc)));
}


Measured memory_bytes: 4352
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine
 
main = do
  [h, a] <- readIntList
  print $ (h + a - 1) `div` a



Measured memory_bytes: 380
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;

  vector<ll> a(n);
  vector<ll> a_sum(n + 1);
  a_sum[0] = 0;
  REP(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  REP(i, n) a_sum[i + 1] = a_sum[i] + a[i];

  ll l = a[0] + a[0] - 1, r = a[n - 1] + a[n - 1] + 1;

  while(r - 1 > l) {
    ll mid = (l + r) / 2;
    auto f = [&] {
      ll sum = 0;
      REP(i, n) {
        ll t = mid - a[i];
        auto it = lower_bound(a.begin(), a.end(), t);
        if(it != a.end()) sum += a.end() - it;
      }
      return sum >= m;
    };
    if(f()) l = mid;
    else r = mid;
  }

  r = r - 1;

  ll ans = 0, c = 0;
  REP(i, n) {
    ll t = r - a[i];
    auto it = lower_bound(a.begin(), a.end(), t);
    if(it != a.end()) {
      ans += a_sum[n] - a_sum[it - a.begin()] + a[i] * (ll)(a.end() - it);
      c += a.end() - it;
    }
  }

  cout << (ans - r * (c - m)) << endl;
}


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

int main() {
    int n; cin >> n;
    vector<Int> a(n);
    Int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    Int minv = sum;
    Int left_sum = 0;
    rep(i, n) {
        left_sum += a[i];
        minv = min(minv, abs(left_sum-(sum-left_sum)));
    }
    cout << minv << endl;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);
  sort(S.begin(), S.end());
  string ans = "";
  for (int i = 0; i < N; i++) ans += S.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define print(x) printf("%d\n",x)

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

using namespace std;

int rp[100][100], pp[100][100];
int cnt[100][100];

int main(){
  while(int n = getInt()){
    REP(i, n) REP(j, n)
      rp[j][i] = pp[i][j] = getInt();

    REP(i, n) REP(j, n)
      cnt[i][j] = 0;

    REP(i, n){
      int minv = *min_element(pp[i], pp[i] + n);
      int maxv = *max_element(rp[i], rp[i] + n);

      REP(j, n){
	if(minv == pp[i][j]) cnt[i][j]++;
	if(maxv == rp[i][j]) cnt[j][i]++;
      }
    }

    //REP(i, n) { REP(j, n) printf("%d ", cnt[i][j]); puts(""); }

    int ans = 0;
    REP(i, n) REP(j, n) if(cnt[i][j] == 2){
      ans = pp[i][j];
      goto end;
    }
  end:
    print(ans);
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> g[202020];
int color[202020];

bool dfs(int v, int c) {
  color[v] = c;
  REP(i, g[v].size()) {
    if (color[g[v][i]] == c) return false;
    if (color[g[v][i]] == 0 && !dfs(g[v][i], -c)) return false;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  char s[n][n];
  REP(i, n) REP(j, n) cin >> s[i][j];
  REP(i, n) REP(j, n) {
    if (s[i][j] == '1') g[i].push_back(j);
  }
  if (!dfs(0, 1)) {
    cout << -1 << endl;
  } else {
    int dist[n][n];
    const int INF = 1e9;
    REP(i, n) REP(j, n) {
      if (s[i][j] == '1') {
        dist[i][j] = 1;
      } else {
        dist[i][j] = INF;
      }
      if (i == j) dist[i][j] = 0;
    }
    REP(k, n) REP(i, n) REP(j, n) {
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    int ans = 0;
    REP(i, n) REP(j, n) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
    cout << ans + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==b){
		printf("Draw\n");
	}
	else if(a==1){
		printf("Alice\n");
	}
	else if(b==1){
		printf("Bob\n");
	}
	else if(a>b){
		printf("Alice\n");
	}
	else if(a<b){
		printf("Bob\n");
	}
	return 0;
}

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

using namespace std;

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

const int inf = 1000000000;

int main() {

    int N;
    cin >> N;

    vector<int> X(N);

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

    int MIN = X[0];
    int MAX = X[0];

    for(int i = 0; i < N; i++) {
        MIN = min(MIN, X[i]);
        MAX = max(MAX, X[i]);
    }

    int ans = inf;

    for(int i = MIN; i <= MAX; i++) {
        int cost = 0;

        rep(j, N) cost += (X[j] - i) * (X[j] - i);
        ans = min(ans, cost);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[n-r] % self.mod

    def H(self, n, r):
        if (n == 0 and r > 0) or r < 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod

    def rising_factorial(self, n, r):  # 上昇階乗冪 n * (n+1) * ... * (n+r-1)
        return self.fac[n+r-1] * self.facinv[n-1] % self.mod

    def stirling_first(self, n, k):  # 第 1 種スターリング数  lru_cache を使うと O(nk)  # n 要素を k 個の巡回列に分割する場合の数
        if n == k: return 1
        if k == 0: return 0
        return (self.stirling_first(n-1, k-1) + (n-1)*self.stirling_first(n-1, k)) % self.mod

    def stirling_second(self, n, k):  # 第 2 種スターリング数 O(k + log(n))  # n 要素を区別のない k グループに分割する場合の数
        if n == k: return 1  # n==k==0 のときのため
        return self.facinv[k] * sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def balls_and_boxes_3(self, n, k):  # n 要素を区別のある k グループに分割する場合の数  O(k + log(n))
        return sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def bernoulli(self, n):  # ベルヌーイ数  lru_cache を使うと O(n**2 * log(mod))
        if n == 0: return 1
        if n % 2 and n >= 3: return 0  # 高速化
        return (- pow(n+1, self.mod-2, self.mod) * sum(self.C(n+1, k) * self.bernoulli(k) % self.mod for k in range(n))) % self.mod

    def faulhaber(self, k, n):  # べき乗和 0^k + 1^k + ... + (n-1)^k
        # bernoulli に lru_cache を使うと O(k**2 * log(mod))  bernoulli が計算済みなら O(k * log(mod))
        return pow(k+1, self.mod-2, self.mod) * sum(self.C(k+1, j) * self.bernoulli(j) % self.mod * pow(n, k-j+1, self.mod) % self.mod for j in range(k+1)) % self.mod

    def lah(self, n, k):  # n 要素を k 個の空でない順序付き集合に分割する場合の数  O(1)
        return self.C(n-1, k-1) * self.fac[n] % self.mod * self.facinv[k] % self.mod

    def bell(self, n, k):  # n 要素を k グループ以下に分割する場合の数  O(k**2 + k*log(mod))
        return sum(self.stirling_second(n, j) for j in range(1, k+1)) % self.mod


def main():
    N, K = map(int, input().split())
    mod = 10**9+7
    sign = 1
    L = []
    comb = Combination(202020)
    ans = 0
    for n_zeroes in range(min(K+1, N)):
        a = comb.C(N, n_zeroes) * comb.H(N-n_zeroes, n_zeroes) % mod
        ans += a
    print(ans % mod)

main()


Measured memory_bytes: 25004
# D Anything Goes to Zero

n = int(input())
x = input()

original_pop_count = x.count("1")
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
  if one_pop_count != 0:
    one_mod = (one_mod * 2 + int(b)) % one_pop_count
  zero_mod = (zero_mod * 2 + int(b)) % zero_pop_count

#fの前計算
f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
  pop_count[i] = pop_count[i//2] + i % 2
  f[i] = f[i % pop_count[i]] + 1

#pow2の前計算
one_pow2 = [1] * 220000
zero_pow2 = [1] * 220000
for i in range(1, 220000):
  if one_pop_count != 0:
    one_pow2[i] = one_pow2[i-1] * 2 % one_pop_count
  zero_pow2[i] = zero_pow2[i-1] * 2 % zero_pop_count

for i in range(n-1, -1, -1):
  if x[n-1-i] == "1":
    if one_pop_count != 0:
      nxt = one_mod
      nxt -= one_pow2[i]
      nxt %= one_pop_count
      print(f[nxt] + 1)
    else:
      print(0)
  if x[n-1-i] == "0":
    nxt = zero_mod
    nxt += zero_pow2[i]
    nxt %= zero_pop_count
    print(f[nxt] + 1)

Measured memory_bytes: 30296
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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 = 100000; 

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

    vector<ll> a(n, 0);
    vector<ll> b(n, 0);
    vector<ll> c(n, 0);

    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = 0; i < n; i++) cin >> b[i];
    for(ll i = 0; i < n; i++) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ll x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll y = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        ans += x * (n - y);
    }

    cout << ans << endl;

    
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[100 + 1];
  scanf("%s", s);
  int c[26] = {};
  for (int i = 0; i < strlen(s); i++) {
    c[s[i] - 'a']++;
  }
  char *ans = "Yes";
  for (int i = 0; i < 26; i++) {
    if (c[i] % 2 != 0) {
      ans = "No";
      break;
    }
  }
  puts(ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<" "
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    int minnum = 200050;
    int cnt = 0;
    int n; cin>> n;
    vector<int> tmp;
    vector<int> p(n);
    forin(p, n);
    for(int i=0; i<n; i++){
        tmp.push_back(p[i]);
        minnum = min(minnum, p[i]);
        if(minnum == p[i]) cnt++;
    }
    cout<< cnt << endl;
}


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

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

  int v[N];
  int w[N];
  for(int i=0; i<N; i++)
    cin>>v[i]>>w[i];

  int DP[N+1][W+1];
  for(int i=0; i<W+1; i++)
    DP[N][i]=0;

  for(int i=N-1; i>=0; i--)
    for(int j=0; j<=W; j++)
      if(j<w[i])
        DP[i][j]=DP[i+1][j];
      else{
        if(DP[i+1][j]>DP[i+1][j-w[i]]+v[i])
          DP[i][j]=DP[i+1][j];
        else
          DP[i][j]=DP[i+1][j-w[i]]+v[i];
      }
  cout<<DP[0][W]<<endl;
  return 0;
}

Measured memory_bytes: 7008
N = int(input())
h = list(map(int, input().split()))
cnt = 0 
while True:
  pre = False
  for i in range(N):
    if h[i] > 0:
      if pre:
        h[i] -= 1
      else:
        h[i] -= 1
        pre = True
        cnt += 1
    else:
      pre = False
  if sum(h) == 0:
    break
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
void solve(){
    int N, X, T;    
    read(N, X, T);
    int ans = N / X * T;
    if( N % X){
        ans += T;
    }
    cout << ans << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

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

		int n = scan.nextInt();
		int[] e = new int[n];
		for (int i = 0; i < n; i++)
			e[i] = scan.nextInt();

		int r = 0;
		for (int i = 0; i < n; i++)
			if (isPrime(e[i]))
				r++;
		System.out.println(r);

		scan.close();
		System.exit(0);
	}

	private static boolean isPrime(int x) {
		double max=Math.sqrt(x);
		for (int i = 2; i <= max; i++)
			if (x % i == 0)
				return false;
		return true;
	}
}

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

int n;
vector<int> e[100005];
int dp[100005][2];
int mod = 1e9+7;

int dfs(int at,int col,int par) {
	if (dp[at][col] != -1) return dp[at][col];

	int ret = 1;
	for (int i=0; i<e[at].size(); i++) {
		if (e[at][i] == par) continue;
		if (col == 1) {
			ret = (ret*1LL*dfs(e[at][i],0,at))%mod;
		}
		else {
			ret = (ret*1LL*(dfs(e[at][i],0,at)+dfs(e[at][i],1,at)))%mod;
		}
	}
	dp[at][col] = ret;
	return dp[at][col];
}

int main() {
	scanf("%d",&n);
	for (int i=0; i<n-1; i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	memset(dp,-1,sizeof(dp));
	printf("%d\n",(dfs(1,0,-1)+dfs(1,1,-1))%mod);
	return 0;
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    ll x, y; cin>>x>>y;
    ll ans=x;
    for(int i=1; ; i++){
        ans*=2;
        if(ans==y){
            cout << i+1 << endl;
            return 0;
        }
        else if(ans>y){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int to,nxt,id,color;
}e[200001];
inline bool cmp(node x,node y){
	if(x.id!=y.id)return x.id<y.id;
	return x.color>y.color;
}
int n,cnt,head[100001],ans,x,y;
inline void Add(int xx,int yy,int iidd){
	e[++cnt].to=yy;
	e[cnt].nxt=head[xx];
	e[cnt].id=iidd;
	head[xx]=cnt;
}
void Df5(int xx,int fa,int lst){
	int cc=0;
	for(register int i=head[xx];i;i=e[i].nxt){
		if(e[i].to!=fa){
			++cc;
			if(cc==lst)++cc;
			e[i].color=cc;
			if(cc>ans)ans=cc;
			Df5(e[i].to,xx,cc);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		Add(x,y,i);
		Add(y,x,i);
	}
	Df5(1,0,0);
	printf("%d\n",ans);
	sort(e+1,e+(n-1)*2+1,cmp);
	for(register int i=1;i<=(n-1)*2;i++)if(e[i].id!=e[i-1].id)printf("%d\n",e[i].color);
}

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

int main(){
int n;
int k;
cin >> n;
cin >> k;
int a[k];
int b[k];
int c;
c=0;
while(c<k){
cin >> a[c];
cin >> b[c];
c=c+1;}
int d;
int e;
int f;
int g;
c=0;
while(c<k){
d=a[c];
e=b[c];
f=n+1-a[c];
g=n+1-b[c];
if(d>e){d=e;}
if(d>f){d=f;}
if(d>g){d=g;}
e=d%3;
if(e==0){e=3;}
cout << e <<endl;
c=c+1;}
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size()-1;
    vector<int>a(4);
    for(int i=0;i<4;++i)
        a.at(i)=s.at(i)-'0';
    for(int i=0,sum;i<(1<<n);++i){
        bitset<3>b=i;
        sum=a.at(0);
        string s;
        s+=a.at(0)+'0';
        for(int j=0;j<3;++j){
            if(b.test(j)){
                sum+=a.at(j+1);
                s+='+';
                s+=a.at(j+1)+'0';
            } else {
                sum-=a.at(j+1);
                s+='-';
                s+=a.at(j+1)+'0';
            }
        }
        if(sum==7){
            s+="=7\n"s;
            cout<<s;
            return 0;
        }
    }
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int n,t;
  vector <int> v, tmp, ans;
  int m;
  int p,x;

  scanf("%d",&n);
  REP (i, n) {
    scanf("%d",&t);
    v.push_back(t);
  }

  scanf("%d",&m);
  REP (i, m) {
    tmp = v;
    scanf("%d %d",&p,&x);
    tmp.at(p - 1) = x;
    ans.push_back(accumulate(tmp.begin(), tmp.end(), 0));
  }

  REP (i, m) printf("%d\n",ans.at(i));
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int nums[10000];
	int i, j, n, size, half;
	while(scanf("%d", &n), n){
		size = 0;
		half = (n-1) / 2;
		for(i=1; i<n; ++i)
			nums[size++] = (i*i) % n;

		sort(nums, nums + size);
		size = distance(nums, unique(nums, nums + size));

		vi ans(half+1, 0);
		for(i=0; i<size; ++i){
			for(j=0; j<i; ++j){
				int p = abs(nums[i]-nums[j]);
				if(p>half) p = n - p;
				++ans[p];
			}
		}
		for(i=1; i<=half; ++i)
			printf("%d\n", ans[i]*2);
	}

	return 0;
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i], a[i]--;
    int pos = 0;
    int ans = 0;
    while(1){
        pos = a[pos];
        ans++;
        if(pos == 1){
            cout << ans << endl;
            return 0;
        }
        if(ans >= n){
            cout << -1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
  cin >> n >> s;
  for(int i=0;i<s.length();i++){
    if((int)(s[i]+n)>(int)'Z')s[i] = (char)(s[i]+n-26);
    else(s[i] = (char)(s[i]+n));
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  string s;
  string t;
  cin>>s>>t;
  int sl = s.length();
  int tl = t.length();
  int k = min(sl,tl);
  int count = 0;
  for(int i = 0 ; i < k ; i++){
    if(s[i]!=t[i]){
      count++;
    }
  }
  cout<<count<<endl;
}


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

int main() {
  string S;
  cin>>S;
  int count=0;
  for(int i=0;i<S.size();i++){
    if(i%2+1==1){
      if(S.at(i)!='L'){
        count++;
      }
    }
    else{
      if(S.at(i)!='R'){
        count++;
      }
    }
  }
  if(count==S.size()){
    cout<<"Yes"<<endl;
  }
  else{
     cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool samax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool samin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <string>

int main() {
	::std::string s;
	::std::cin >> s;
	::std::reverse(s.begin(), s.end());
	u64 ans{ 0 };
	usize cnt{ 0 };
	for (const auto i : rep<>(0, s.size())) {
		if (s[i] == 'B')
			ans += i - (cnt++);
	}
	::std::cout << ans << ::std::endl;
	return 0;
}


Measured memory_bytes: 1336
N,M,X=map(int, input().split())
C=[]
A=[]
for i in range(N):
  d=list(map(int, input().split()))
  c1=d[0]
  c2=d[1:]
  C.append(c1)
  A.append(c2)
R=[0]*M
for i in range(N):
  for j in range(M):
    R[j]+=A[i][j]
    
if min(R)<X:
  print(-1)
  exit()

import itertools
D=list(itertools.product([0,1], repeat=N))
ans=(10**5)*12
for i in range(len(D)):
  L=[0]*M
  cnt=0
  for j in range(N):
    cnt+=D[i][j]*C[j]
    for k in range(M):
      L[k]+=D[i][j]*A[j][k]
  if min(L)>=X:
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 9520
{$R+,S+,Q+,I+,O-}
{R-,S-,Q-,I-,O+}
// Code By H~$~C

uses math;

type
  int32 = int64;
  double = extended;
  bool = boolean;

const
  inf = 1061109567;
  lnf = 4557430888798830399;
  Maxn = 200005;
  LOG = 32;

var
  i, j: int32;
  swap_tmp, x, y, z: int64;
  n, T, sza, szb, ans: int64;
  a: array [0 .. Maxn, 0 .. 1] of int64;
  b: array [0 .. Maxn] of int64;
  dp: array [0 .. LOG] of int64;

function qsort_less(i, j: int32): bool;
begin
  qsort_less := (a[j][0] * (a[i][1] + 1) < (a[i][0] * (a[j][1] + 1)));
end;
procedure qsort_swap(i, j: int32);
begin
  a[0] := a[i];
  a[i] := a[j];
  a[j] := a[0];
end;
procedure qsort(_l, _r: int32);
  var i, j, _p: int32;
begin
  if (_r = _l) then exit;
  i := _l; j := _r;
  _p := _l;
  repeat
    while qsort_less(i, _p) do inc(i);
    while qsort_less(_p, j) do dec(j);
    if (i <= j) then begin
      qsort_swap(i, j);
      inc(i); dec(j);
    end;
  until (i > j);
  if (i < _r) then qsort(i, _r);
  if (j > _l) then qsort(_l, j);
end;

function qsort2_less(i, j: int32): bool;
begin
  qsort2_less := (b[i] < b[j]);
end;
procedure qsort2_swap(i, j: int32);
begin
  b[0] := b[i];
  b[i] := b[j];
  b[j] := b[0];
end;
procedure qsort2(_l, _r: int32);
  var i, j, _p: int32;
begin
  if (_r = _l) then exit;
  i := _l; j := _r;
  _p := _l;
  repeat
    while qsort2_less(i, _p) do inc(i);
    while qsort2_less(_p, j) do dec(j);
    if (i <= j) then begin
      qsort2_swap(i, j);
      inc(i); dec(j);
    end;
  until (i > j);
  if (i < _r) then qsort2(i, _r);
  if (j > _l) then qsort2(_l, j);
end;

begin
//  assign(input,'in'); reset(input);
//  assign(output,'out'); rewrite(output);
  randomize;
  
  readln(n, T);
  sza := 0; szb := 0;
  for i := 1 to n do begin
    readln(x, y);
    if (x = 0) then begin
      inc(szb);
      b[szb] := y;
    end
    else begin
      inc(sza);
      a[sza, 0] := x;
      a[sza, 1] := y;
    end;
  end;
  
  for i := 2 to sza do begin
    x := random(i - 1) + 1;
    a[0] := a[x];
    a[x] := a[i];
    a[i] := a[0];
  end;
  qsort(1, sza);
  
  for i := 1 to LOG do dp[i] := T + 1;
  dp[0] := 0;
  for i := 1 to sza do begin
    for j := LOG - 1 downto 0 do begin
      if (dp[j] > T) then continue;
      if (dp[j + 1] > dp[j] + 1 + (dp[j] + 1) * a[i][0] + a[i][1]) then begin
        dp[j + 1] := dp[j] + 1 + (dp[j] + 1) * a[i][0] + a[i][1];
      end;
    end;
  end;
  
  for i := 2 to szb do begin
    x := random(i - 1) + 1;
    b[0] := b[x];
    b[x] := b[i];
    b[i] := b[0];
  end;
  qsort2(1, szb);
  ans := 0;
  for i := 0 to LOG do begin
    if (dp[i] > T) then continue;
    x := T - dp[i];
    y := 0;
    for j := 1 to szb do begin
      if (x > b[j]) then begin
        dec(x, b[j] + 1);
        inc(y);
      end
      else break;
    end;
    if (i + y > ans) then ans := i + y;
  end;
  
  writeln(ans);
  
  close(input);
  close(output);
end.


Measured memory_bytes: 3840
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int A_price[100000], B_price[100000];

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

	int A_min = INF;
	int B_min = INF;

	for (int i=0; i<A; i++) {
		cin >> A_price[i];
		A_min = min(A_min, A_price[i]);
	}

	for (int i=0; i<B; i++) {
		cin >> B_price[i];
		B_min = min(B_min, B_price[i]);
	}

	int x, y, c;
	int M_price_min = INF;
	for (int i=0; i<M; i++) {
		cin >> x >> y >> c;
		x--;
		y--;
		M_price_min = min(M_price_min, A_price[x] + B_price[y] - c);
	}

	int ans = min(A_min + B_min, M_price_min);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (a >= b) {
        cout << "delicious" << endl;
    } else if (b-a <= x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, N;
    scan(H, N);
    auto A = new long[](N);
    auto B = new long[](N);
    foreach (i; 0 .. N)
        scan(A[i], B[i]);
    auto ans = new long[](H + 1);
    ans[] = long.max >> 2;
    ans[H] = 0;
    foreach_reverse (h; 1 .. H + 1)
        foreach (i; 0 .. N)
        {
            ans[max(0, h - A[i])] = ans[max(0, h - A[i])].min(ans[h] + B[i]);
        }
    writeln(ans[0]);
}


Measured memory_bytes: 636
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    x,y = map(int, input().split())
    flag = False
    for i in range(x+1):
        
        if 2*(x-i) + 4*i == y:
            flag = True
    
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9620
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
int main ()
{
 
long int a,b,n,ans;
cin>>a>>b>>n;
if(n==b)
{
    ans=floor(a*(b-1)/b);
}
else if(n>b)
{
    ans=floor(a*(b-1)/b);
}
else if(n<b)
{
    ans=floor(a*n/b);
}
cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  long result = 0;
  for (int a = 0; a < N-2; a++) {
    for (int b = a+1; b < N-1; b++) {
      for (int c = b+1; c < N; c++) {
        if (L[c] >= L[a] + L[b]) break;
        if (L[a] < L[b] + L[c] && L[b] < L[a] + L[c]) result++;
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int a[100002], cnt[100002];
int main(){
    int n, ans = 1;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    for(int i=1;i<=n;i++) cnt[a[i]]++;
    for(int i=n-1;i>=0;i-=2){
        if(cnt[i] != 2 && i != 0){
            printf("0\n");
            return 0;
        }
        else if(cnt[i] == 2) ans = ans*2%mod;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include<stdio.h>

int max_return(int a, int b, int c)
{
  int max;
  max = a;

  if(max < b) max = b;
  if(max < c) max = c;

  return max;

}


int main(){

	int n,nn;
	int a[10000],b[10000],c[10000],d[10000],e;
	

	scanf("%d",&n);
	for(nn=0;nn<n;nn++){
		scanf("%d %d %d",&a[nn],&b[nn],&c[nn]);
		d[nn]= max_return(a[nn],b[nn],c[nn]);
		 if(a[nn]==d[nn]){
			a[nn]=0;
			goto out;
		}
		if(b[nn]==d[nn]){
			b[nn]=0;
			goto out;
		}
		if(c[nn]==d[nn]){
			c[nn]=0;
			goto out;
		}
		out:;
	}
	for(nn=0;nn<n;nn++){
		if(d[nn]*d[nn]==a[nn]*a[nn]+b[nn]*b[nn]+c[nn]*c[nn]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
        return 0;
} 

Measured memory_bytes: 0
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] hens = new int[n];
		for(int i=0; i<n; i++){
			hens[i] = sc.nextInt();
		}
		
		int max = 0;
		int sum = 0;
		for(int i=0; i<n; i++){
			if(hens[i] > max){
				max = hens[i];
			}
			sum += hens[i];
		}
		
		if(max*2 >= sum){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 24916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main()
{
    int n;
    vector<vector<int>> txy;
    int tmp1, tmp2, tmp3;

    cin >> n;
    txy.resize(n);
    for (int i = 0; i < n; i++)
    {
        txy[i].resize(3);
    }

    for (int i = 0; i < n; i++)
    {
        cin >> tmp1 >> tmp2 >> tmp3;
        txy[i][0] = tmp1;
        txy[i][1] = tmp2;
        txy[i][2] = tmp3;
    }

    int oldt = 0, oldx = 0, oldy = 0;
    int subt = 0;
    int absx, absy;
    for (int i = 0; i < n; i++)
    {
        subt = txy[i][0] - oldt;
        absx = abs(txy[i][1] - oldx);
        absy = abs(txy[i][2] - oldy);

        if (subt >= absx + absy && ((subt % 2 == 0 && (absx + absy) % 2 == 0) || (subt % 2 == 1 && (absx + absy) % 2 == 1)))
        {
            oldt = txy[i][0];
            oldx = txy[i][1];
            oldy = txy[i][2];
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 k, t;
	std::cin >> k >> t;
	uint32 c[101] = {};
	rep(i, 0, t)
		std::cin >> c[i];
	uint32 max = 0;
	rep(i, 0, 101) {
		max = std::max(max, c[i]);
	}
	if (k & 1) {
		if (max <= (k >> 1) + 1) {
			max = 0;
		}
		else {
			max = (max - (k >> 1) - 1) << 1;
		}
	}
	else {
		if (max <= (k >> 1)) {
			max = 0;
		}
		else {
			max = ((max - (k >> 1)) << 1) - 1;
		}
	}
	std::cout << max << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <ctime>
#include <numeric>


#ifndef M_PI
#define M_PI 3.141592653589
#endif
#define int long long
#define double long double

#ifdef TIME
#define start cin.tie(NULL); cout.tie(NULL); cout.setf(ios::fixed); cout.precision(10); ios_base::sync_with_stdio(false);int32_t START = clock()
#define finish cout << "\ntime: " << (clock() - START) / (CLOCKS_PER_SEC * 1.0); return 0
#endif

#ifndef TIME
#define start cin.tie(NULL); cout.tie(NULL); cout.setf(ios::fixed); cout.precision(10); ios_base::sync_with_stdio(false)
#define finish return 0
#endif

using namespace std;


//vector input
template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &i : vec) {
        cin >> i;
    }
    return is;
}

//pair output
template<typename E>
ostream &operator<<(ostream &os, pair<E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//"map" pair output
template<typename E>
ostream &operator<<(ostream &os, pair<const E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//vector output
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
    for (T i : vec) {
        os << i << ' ';
    }
    return os;
}

//2 dimensional vector output
template<typename T>
ostream &operator<<(ostream &os, vector<vector<T> > &vec) {
    for (vector<T> i : vec) {
        os << i << '\n';
    }
    return os;
}


int32_t main() {
    start;

    int n;
    cin >> n;
    vector<int> a(n);
    int m = 1e9 + 7;
    vector<int> b(n + 1);


    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i + 1] = (b[i] + a[i]) % m;
    }

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        ans += (b[i] * a[i]) % m;
        ans %= m;
    }

    cout << ans << '\n';

    finish;
}

Measured memory_bytes: 6372
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int n,arr[100000001],arr2[100000001];
vector<int> que;
int main(){
	
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
		arr2[i]=arr[i];
	}
	sort(arr2,arr2+n);
	int sum=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int fa=1;
//			for(int k=0;k<que.size();k++){
//				if(arr[j]==que[k]){
//					fa=0;
//					break;
//				}
//			}
			if(fa){
				if(arr[j]==arr2[i]&&arr[j]!=arr[i]){
					swap(arr[i],arr[j]);
//					que.push_back(arr[i]);		
//					que.push_back(arr[j]);
//					for(int i=0;i<n;i++){
//						printf("%d ",arr[i]);
//					}
//					printf("\n");
					sum++;
					break;
				}
			}
		} 
	}
//	printf("%d",sum);
//	int fase=1;
//	for(int i=0;i<n;i++){
//		if(arr[i]!=arr2[i]){
//			fase=0;
//			break;
//		}
//	}
	if(sum==1||sum==0){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
} 

Measured memory_bytes: 2936