akhauriyash/Code-Regression huggingface dataset:
use std::io;

const MODNUM: usize = 1_000_000_007;
const FACTORIAL_MAX: usize = 2000;

struct CombinationMod {
    //階乗のメモ
    factorial_memo: Vec<Option<usize>>,
    //階乗の逆元のメモ
    factorial_inv_memo: Vec<Option<usize>>,
}

impl CombinationMod {
    fn new() -> CombinationMod {
        let mut obj = CombinationMod {
            factorial_memo: vec![None; FACTORIAL_MAX + 1],
            factorial_inv_memo: vec![None; FACTORIAL_MAX + 1],
        };
        obj.factorial_memo[0] = Some(1);
        obj.factorial_inv_memo[0] = Some(1);
        obj
    }

    //階乗を求める。
    fn get_factorial(&mut self, n: usize) -> usize {
        match self.factorial_memo[n] {
            Some(s) => s,
            None => {
                let buf = self.get_factorial(n - 1) * n % MODNUM;
                self.factorial_memo[n] = Some(buf);
                buf
            }
        }
    }
    //階乗の逆元を求める。
    fn get_factorial_inv(&mut self, n: usize) -> usize {
        match self.factorial_inv_memo[n] {
            Some(s) => s,
            None => {
                let buf = self.get_factorial_inv(n - 1) * modinv(n) % MODNUM;
                self.factorial_inv_memo[n] = Some(buf);
                buf
            }
        }
    }
    fn calc_combination(&mut self, n: usize, r: usize) -> usize {
        if n < r {
            return 0;
        }
        let mut buf: u64 =
            ((self.get_factorial(n) as u64) * (self.get_factorial_inv(r) as u64)) % MODNUM as u64;
        buf = (buf * (self.get_factorial_inv(n - r) as u64)) % MODNUM as u64;
        buf as usize
    }
}

//MODNUMを法とするnumの逆元を求める。
fn modinv(num: usize) -> usize {
    modpow(num, MODNUM - 2)
}
fn modpow(mut a: usize, mut p: usize) -> usize {
    let mut ans: usize = 1;
    while p > 0 {
        if p & 1 != 0 {
            ans = (ans * a) % MODNUM;
        }
        a = (a * a) % MODNUM;
        p >>= 1;
    }
    ans
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let v: Vec<&str> = input.trim().split_whitespace().collect();

    let n: usize = v[0].parse().unwrap();
    let k: usize = v[1].parse().unwrap();

    let mut obj = CombinationMod::new();

    for i in 1..k + 1 {
        let ans = (obj.calc_combination(n - k + 1, i) as u64
            * obj.calc_combination(k - 1, i - 1) as u64)
            % MODNUM as u64;
        println!("{}", ans);
    }
}

Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
long int sum=0;
int main()
{
    int n;
    cin>>n;
vector <int> a(n);

for (int i=0;i<n;i++)
cin>>a[i];
sort (a.begin(),a.end());

for (int i=0;i<n-2;i++)
{for (int j=i+1;j<n-1;j++)
{for (int k=j+1;k<n;k++)
if (a[i]+a[j]>a[k])
sum++;
}
}
cout <<sum;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

long long ans;
long long n;

void solve(long long x){
  if(x>n) return;
  long long data=x;
  int count[10]={0},flag=0;
  while(true){
    count[x%10]++;
    x/=10;
    if(x==0) break;
  }
  for(int i=3;i<=7;i+=2){
    if(count[i]==0) flag=1;
  }
  if(flag==0) ans++;
  for(int i=3;i<=7;i+=2){
    solve(data*10+i);
  }
}

int main(){
  cin>>n;
  solve(0);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };
}

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)*}
    };

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        H: usize,
        W: usize,
        board: [chars; H],
    }
    for h in 0..H as i64 {
        for w in 0..W as i64 {
            if board[h as usize][w as usize] == '.' {
                continue;
            }
            if board[max(0, h - 1i64) as usize][w as usize] == '.'
                && board[h as usize][max(0, w - 1i64) as usize] == '.'
                && board[h as usize][min((W - 1) as i64, w + 1i64) as usize] == '.'
                && board[min((H - 1) as i64, h + 1i64) as usize][w as usize] == '.'
            {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4476
main = getContents >>= putStrLn . solve 0 1 . map read . words

solve cnt _ (n:[]) = if n - 2 <= cnt then "YES" else "NO"
solve cnt i (n:p:ps) = if i == p
    then solve (cnt + 1) (i + 1) (n:ps)
    else solve cnt (i + 1) (n:ps)

Measured memory_bytes: 636
n = int(input())
v = list(map(int, input().split()))

odd = [[0, i] for i in range(10**5 + 1)]
even = [[0, i] for i in range(10**5 + 1)]

for i, vi in enumerate(v, 1):
  if i % 2 == 0:
    even[vi][0] += 1
  
  else:
    odd[vi][0] += 1

odd.sort(reverse=True)
even.sort(reverse=True)

no1, o1 = odd[0]
no2, o2 = odd[1]
ne1, e1 = even[0]
ne2, e2 = even[1]


if e1 == o1:
  ans = min((n//2-ne1)+(n//2-no2), (n//2-ne2)+(n//2-no1))
else:
  ans = (n//2-ne1) + (n//2-no1)

print(ans)

Measured memory_bytes: 34196
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i=0; i<N;i++) {
			X[i]=sc.nextInt();
		}
		int[] Y = X.clone();
		Arrays.sort(Y);
		int k = Y[N/2-1];
		int g = Y[N/2];
		for(int i=0;i<N;i++) {
			if(X[i]<=k) {
				System.out.println(g);
			}else{
				System.out.println(k);
			}
		}
	}
}

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

using namespace std;

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

	int a, b,c,d;
	cin >> a >> b >> c >> d;

	while (1) {
		c -= b;
		if (c <= 0) { cout << "Yes\n"; break; }

		a -= d;
		if (a <= 0) { cout << "No\n"; break; }

	}
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 10;
const ll MOD = 1e9 + 7;

ll dp[MAX_N][2];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string L;
    cin >> L;
    dp[0][0] = 1;
    for (int i = 0; i < L.length(); i++) {
        if (L[i] == '0') {
            dp[i + 1][0] = (dp[i + 1][0] + dp[i][0]) % MOD;
            dp[i + 1][1] = (dp[i + 1][1] + (3 * dp[i][1]) % MOD) % MOD;
        }
        else {
            dp[i + 1][0] = (dp[i + 1][0] + (2 * dp[i][0]) % MOD) % MOD;
            dp[i + 1][1] = ((dp[i + 1][1] + (3 * dp[i][1]) % MOD) % MOD + dp[i][0]) % MOD;
        }
    }
    cout << (dp[L.length()][0] + dp[L.length()][1]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 2000
#include<bits/stdc++.h>
using namespace std;
#define f(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define d(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ri register int
#define ll long long
#define il inline
#define _ 19260817
int max(int x, int y) {return x>y?x:y;} int min(int x, int y) {return x<y?x:y;}
int n, m,a[_], sum, ans=1;
double lim;
int cmp(int a, int b) {return a>b;}
int main(){
  scanf("%d%d", &n, &m);
  f(i,1,n) scanf("%d", &a[i]), sum+=a[i];
  lim = sum/(4.00*m);
  sort(a+1, a+1+n);
  d(i,n,n-m+1) ans &= (!(a[i]<lim));
  puts(ans?"Yes":"No");
  return 0;
}
// sto wyxkk orz


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

int N;
vector<int> L;
vector<int> A;

int main(){
    cin >> N;
    A.resize(3);
    for(int i = 0; i < 3; i++)cin >> A[i];
    L.resize(N);
    for(int i = 0; i < N; i++)cin >> L[i];

    int res = 1 << 29;
    vector<int> bit(3);
    for(bit[0] = 1; bit[0] < (1<<N); ++bit[0]){
        for(bit[1] = 1; bit[1] < (1 <<N); ++bit[1]){
            if(bit[1] & bit[0])continue;
            for(bit[2] = 1; bit[2] < (1<<N); ++bit[2]){
                if(bit[2] & bit[0])continue;
                if(bit[2] & bit[1])continue;

                vector<int> sums(3, 0), nums(3, 0);
                for(int i = 0; i < N; i++){
                    for(int j = 0; j < 3; j++){
                        if(bit[j] & (1 << i)){
                            sums[j] += L[i];
                            nums[j]++;
                        }
                    }
                }

                int score = 0;
                for(int i = 0; i < 3; i++){
                    score += abs(sums[i] - A[i]);
                    score += (nums[i] - 1) * 10;
                }
                res = min(res, score);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
s = input()
L = ""
for c in s:
    if c!="x":
        L += c
n = len(L)
for i in range(n):
    if L[i] == L[-1-i]:
        continue
    else:
        print(-1)
        exit()
x = 0
il = 0
ir = 0
ans = 0
for c in L[:(n+1)//2]:
    x = 0
    while s[il]=="x":
        x+=1
        il+=1
    il+=1
    while s[-1-ir]=="x":
        x-=1
        ir+=1
    ir+=1
    ans += abs(x)
print(ans)


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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0] == a[2]){
      cout << "No" << endl;
  }else if(a[0]==a[1] || a[1]==a[2]){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
  return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

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

signed main() {
  string s;
  cin >> s;

  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      string t = "";
      for (int k = 0; k < n; k++) {
        if (i <= k && k < j) {
          continue;
        } else {
          t.push_back(s[k]);
        }
      }
      if (t == "keyence") {
        puts("YES");
        return 0;
      }
    }
  }

  puts("NO");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
  
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
 
typedef long long int64;
const int INF = 1 << 30;

int main(){
  int n, m, s[100000] = {};
  scanf("%d %d", &n, &m);
  for(int i = 1; i < n; i++){
    scanf("%d", &s[i]);
    s[i] += s[i - 1];
  }
  int sum = 0, idx = 1;
  while(m--){
    int a;
    scanf("%d", &a);
    a += idx;
    (sum += abs(s[a - 1] - s[idx - 1])) %= 100000;
    idx = a;
  }
  printf("%d\n", sum);
}

Measured memory_bytes: 1588
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;

    vector<int> A(N);
    for (auto& a : A) cin >> a;

    int sum = accumulate(A.begin(), A.end(), 0);
    int ans = 0;
    for (auto a : A) {
        if (a * N <= sum) ++ans;
    }
    cout << ans << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

template<typename a>
struct S013 {
  std::vector<a> xs;
  S013(const std::vector<a>& ys) {
    xs = ys;
    std::sort(xs.begin(), xs.end());
    xs.erase(std::unique(xs.begin(), xs.end()), xs.end());
  }
  a operator [] (long i) {
    return xs[i];
  }
  long size() {
    return xs.size();
  }
};

struct Solver {
  std::vector<long> xs;
  Solver() {
    S002 r;
    r >3>= xs;
  }
  void solve() {
    S013<long> ys(xs);
    printf("%ld\n", ys.size());
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int a, b;
    cin >> a >> b;
    int m = 1;
    int d = 1;
    int ans = 0;
    for (int i = 0; i < 365; i++)
    {
        if (d == 29 && m == 2)
        {
            m++;
            d = 1;
        }
        if (d == 31 && (m == 4 || m == 6 || m == 9 || m == 11))
        {
            m++;
            d = 1;
        }
        if (d == 32 && (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12))
        {
            m++;
            d = 1;
        }
        if (m == d)
        {
            ans++;
        }
        if (m == a && d == b)
        {
            break;
        }
        d++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	vector<int> n(3);
	rep(i, 3)	cin >> n[i];

	int cnt5 = 0, cnt7 = 0;
	rep(i, 3)
	{
		if (n[i] == 5)
			cnt5++;
		if (n[i] == 7)
			cnt7++;
	}

	if (cnt5 == 2 && cnt7 == 1)
		cout << "YES";
	else
		cout << "NO";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    int v[n];
    for (auto &vi:v) cin >> vi;
    sort(v, v+n);
    double sum = v[0];
    for (auto vi:v) {
        sum += (double) vi;
        sum /= 2;
    }
    cout << setprecision(10) << sum << '\n';
    return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  vector<ll> w(N), v(N);
  rep0(i, N) cin >> w[i] >> v[i];

  vector<ll> v0, v1, v2, v3;
  
  rep0(i, N) {
    if (w[i] == w[0] + 0) v0.push_back(v[i]);
    else if (w[i] == w[0] + 1) v1.push_back(v[i]);
    else if (w[i] == w[0] + 2) v2.push_back(v[i]);
    else if (w[i] == w[0] + 3) v3.push_back(v[i]);
  }
  sort(v0.begin(), v0.end()); v0.push_back(0); reverse(v0.begin(), v0.end());
  sort(v1.begin(), v1.end()); v1.push_back(0); reverse(v1.begin(), v1.end());
  sort(v2.begin(), v2.end()); v2.push_back(0); reverse(v2.begin(), v2.end());
  sort(v3.begin(), v3.end()); v3.push_back(0); reverse(v3.begin(), v3.end());
  // SHOW(v0);SHOW(v1);SHOW(v2);SHOW(v3);

  ll temp;
  temp = 0; rep(i, 1, v0.size()) v0[i] += v0[i - 1];
  temp = 0; rep(i, 1, v1.size()) v1[i] += v1[i - 1];
  temp = 0; rep(i, 1, v2.size()) v2[i] += v2[i - 1];
  temp = 0; rep(i, 1, v3.size()) v3[i] += v3[i - 1];

  ll ans = 0;
  rep0(i0, v0.size()) {
    if (w[0] * i0 > W) break;
    ans = max(ans, v0[i0]);
    // cout << i0 << ":" << ans << BR;

    rep0(i1, v1.size()) {
      if (w[0] * i0 + (w[0] + 1) * i1 > W) break;
      ans = max(ans, v0[i0] + v1[i1]);
      // cout << i0 << SP << i1 << ":" << ans << BR;

      rep0(i2, v2.size()) {
        if (w[0] * i0 + (w[0] + 1) * i1 + (w[0] + 2) * i2 > W) break;
        ans = max(ans, v0[i0] + v1[i1] + v2[i2]);
        // cout << i0 << SP << i1 << SP << i2 << ":" << ans << BR;

        rep0(i3, v3.size()) {
          if (w[0] * i0 + (w[0] + 1) * i1 + (w[0] + 2) * i2 + (w[0] + 3) * i3 > W) break;
          ans = max(ans, v0[i0] + v1[i1] + v2[i2] + v3[i3]);
          // cout << i0 << SP << i1 << SP << i2 << SP << i3 << ":" << ans << BR;
        }
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define x first
#define y second
typedef long long LL;
typedef pair<int, int> PII;
void R(char &c){c = getchar();};void R(string &s){scanf("%s",s.c_str());}void R(char s[]){scanf("%s",s);}template<typename T>void R(T&x){int f=1;x=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch-48);ch=getchar();}x*=f;}template<typename T,typename...Args>void R(T&x,Args&...args){R(x),R(args...);}void _W(const string&s){printf("%s",s.c_str());}void _W(const char&c){putchar(c);};void _W(const char s[]){printf("%s",s);}template<typename T>void _W(T x){if(x<0){putchar('-');x=-x;}static int dig[130];int top=0;do{dig[top++]=x%10,x/=10;}while(x);while(top)putchar(dig[--top]+48);}template<typename T>void _W(const vector<T> a){for(int i=0;i<SZ(a);++i)_W(a[i]),putchar(' ');}void W(){}template<typename T,typename...Args>void W(const T&x,const Args&...args){_W(x);putchar(sizeof...(args)?' ':'\n');W(args...);}


void solve(){
	int n, m; R(n, m); ;
	vector<int> a(n);
	int sum = 0;
	for(int i = 0; i < n; ++ i){
		R(a[i]); sum += a[i];
	}
	int t = sum / (m << 2); 
	if(sum % (m << 2)) t ++;
	sort(all(a), greater<int>());
	for(int i = 0; i < m; ++ i){
		if(a[i] < t) return W("No"), void();
	}
	W("Yes");
}

signed main(){
	//int T; R(T); while(T -- )
	solve(); return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <queue>


using namespace std;

class Player{
private:
  int  base;

public:
  Player(int i){
    base=1;
  }


  void SetBase(int a){
    this->base =a;
  }

  int GetBase(){
    return this->base;
  }
};

class Baseball{
private:
  int score;
  int out;
  queue<Player> que;

public:
  Baseball(){
      score = out=0;
  }

  void add_hit(int num){
    Player one(1);
    this->que.push(one);
    int length=this->que.size();

    for(int i= 0;i<length;i++){
      Player tmp = this->que.front();
      this->que.pop();
      int tmp_base=tmp.GetBase();
      if((tmp_base+num)>4){
        score++;
      }else{
        tmp.SetBase(tmp_base+num);
        this->que.push(tmp);
      }
    }
  }

  void add_out(){
    this->out++;
  }

  void add_score(){
    this->score++;
  }

  int GetOut(){
    return this->out;
  }

  int GetScore(){
    return this->score;
  }

  void show_score(){
    cout<<this->score<<endl;
  }

};

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

  for(int i=0;i<time;i++){
    Baseball baseball;
    while(baseball.GetOut()!=3){
      string judge;
      cin>>judge;
      if(judge == "HIT"){
        baseball.add_hit(1);
      }else if(judge=="OUT"){
        baseball.add_out();
      }else if(judge=="HOMERUN"){
        baseball.add_hit(4);
      }

    }

    cout<<baseball.GetScore()<<endl;
  }

  return 0;
}



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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define repr(i,n) for( (i)=(n);(i)>0;==(i) )
#define FOR(i,j,n) for( (i)=(j);(i)<(n);++(i) )
#define forr(i,j,n) for( (i)=(j);(i)>(n);--(i) )
#define debg(a) cout<<(a)<<endl;
#define INF 9999999
#define Int long long 
int i,j,k;
int dx,dy;
int a,b,c;
string s,t;

int main(){ 
  cin>>a;
  if(a==25) cout<<"Christmas";
    else if(a==24) cout<<"Christmas Eve";
      else if(a==23) cout<<"Christmas Eve Eve";
        else cout<<"Christmas Eve Eve Eve";


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int main(){
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	int ans=min(min(c*max(x,y)*2,c*min(x,y)*2+a*(x-min(x,y))+b*(y-min(x,y))),a*x+b*y);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long N, std::vector<std::string> S){
    vector<ll> res{0,0,0,0};
    rep(i,N){
        if(S[i] == "AC") res[0]++;
        if(S[i] == "WA") res[1]++;
        if(S[i] == "TLE") res[2]++;
        if(S[i] == "RE") res[3]++;
    }
    cout << "AC x " << res[0] << endl;
    cout << "WA x " << res[1] << endl;
    cout << "TLE x " << res[2] << endl;
    cout << "RE x " << res[3] << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

int main()
{
  ll N,b;
  cin >> N;
  b = 1e15;
  rep(i,5){
    ll w;
    cin >>w;
    b = min(b,w);
  }
  ll ans = (N/b) -1 + 5;
  if(N%b >0){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map;
import java.util.TreeMap;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int[] A = new int[N];

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

        int ans = A[0];
        for(int i=1; i<N; i++){
            int max = Math.max(ans, A[i]);
            int min = Math.min(ans, A[i]);
            while(min!=0){
                if(max%min!=0){
                    int a = min;
                    int b = max % min;
                    max = a;
                    min = b;
                }
                else{
                    ans = min;
                    min = 0;
                }
            }
        }
        System.out.println(ans);
    }
}

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

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vi dp(n,inf);
	dp[0]=0;
	for(int i=0;i<n;i++){
		if(i+1<n) dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		if(i+2<n) dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug == false) {
            return;
        }
        System.out.println(str);
    }

    public static class Edge {
        int u;
        int v;
        int w;

        public Edge(int u, int v, int w) {
            this.u = u;
            this.v = v;
            this.w = w;
        }
    }
    public static class Node {
        List<Edge> edge = new LinkedList<>();
    }

    public static void main(String[] args) {

        int N;
        Node[] node;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            node = new Node[N];
            for (int i = 0; i < N; i++) {
                node[i] = new Node();
            }
            for (int i = 0; i < N - 1; i++) {
                int u = sc.nextInt();
                int v = sc.nextInt();
                int w = sc.nextInt();
                Edge e = new Edge(u, v, w%2);
                node[u-1].edge.add(e);
                node[v-1].edge.add(e);
            }
        }
        int[] distans = new int[N];
        HashSet<Edge> visited = new HashSet<>();
        Deque<Integer> queue = new LinkedList<>();
        queue.push(1);
        distans[0] = 0;
        Integer target;
        while((target = queue.pollFirst()) != null){
            List<Edge> list = node[target -1].edge;
            for(Edge e : list){
                if(visited.contains(e)){
                    continue;
                }else{
                    int d = (distans[target-1] + e.w) %2;
                    int i;
                    if(e.u != target ){
                        i = e.u;
                    }else{
                        i = e.v;
                    }
                    queue.addLast(i);
                    distans[i  -1] = d;
                    visited.add(e);
                }
            }
        }
        for(int i : distans){
            System.out.println(i%2);
        }
    }


}


Measured memory_bytes: 115552
fun main(args: Array<String>) {
    val S = readLine()!!.toCharArray()
    val odd = S.filterIndexed { i, c -> i % 2 == 0 }
    val even = S.filterIndexed { i, c -> i % 2 == 1 }
    println(if (!odd.contains('L') && !even.contains('R')) "Yes" else "No")
}

Measured memory_bytes: 33524
#include <algorithm>
#include <iostream>
#include <atcoder/segtree>

template <typename Monoid>
Monoid Multiply(Monoid left, Monoid right) {
  return left *= right;
}
template <typename Monoid>
Monoid Identity() {
  return {};
}
template <typename Monoid>
using SegmentTree = atcoder::segtree<Monoid, Multiply, Identity>;

struct Monoid {
  int max = 0;
  Monoid& operator*=(const Monoid& right) {
    max = std::max(max, right.max);
    return *this;
  }
};

int main() {
  constexpr int kMaxValue = 300000;
  int N, K;
  std::cin >> N >> K;
  SegmentTree<Monoid> segment_tree(kMaxValue + 1);
  for (int i = 0; i < N; ++i) {
    int A;
    std::cin >> A;
    auto best = segment_tree.prod(std::max(0, A - K), std::min(kMaxValue, A + K) + 1);
    ++best.max;
    segment_tree.set(A, best);
  }
  std::cout << segment_tree.prod(0, kMaxValue + 1).max << std::endl;
  return 0;
}


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

int main() {
    int n ; cin >> n;
    int sum = 0;

    int nn = n;

    while (n != 0){
        sum += n % 10;
        n /= 10;
    }

    if (nn % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define printd(x) printf("%.12f\n", ans);
#define print(x) cout << (x) << endl;
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
#define all(x) (x).begin(),(x).end()
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const ll MOD = 1e9 + 7;
int main(void) {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    ll tmp = min({a, b, c, d, e});

    ll tmp2;
    if (n % tmp == 0) tmp2 = n / tmp;
    else tmp2 = n / tmp + 1;

    cout << 5 + tmp2 - 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
t[101];main(a,b,i){for(t[1]=t[2]=1;;){
if(scanf("%d%d",&a,&b)<2)exit(0);
if(!a){
	for(i=1;i<=101;i++)if(t[i]&1)break;
	puts(i>101?"OK":"NG");memset(t,0,sizeof(t)),t[1]=t[2]=1;
}
t[a]++,t[b]++;
}}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MX = 1000;

int h, w, a, b;
int grid[MX][MX];
int r[MX], c[MX];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> h >> w >> a >> b;
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < w; j++) {
            cout << (j < a);
        }
        cout << '\n';
    }

    for (int i = 0; i < h - b; i++) {
        for (int j = 0; j < w; j++) {
            cout << (j >= a);
        }
        cout << '\n';
    }
}



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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int k;
  Solver(LL k) : k(k){};

  void solve() {
    vector<LL> ans;
    for (int i = 1; i < 10; ++i) {
      ans.push_back(i);
    }
    while (ans.size() < k) {
      ans.push_back(find_next(ans.back()));
    }
    for (int i = 0; i < k; ++i) {
      cout << ans[i] << endl;
    }
  }
  LL find_next(LL x) {
    LL ret = 0;
    double minr = LINF;
    int d = 0;
    {
      LL tmp = x;
      while (tmp > 0) {
        d++;
        tmp /= 10;
      }
    }
    for (int i = d; i >= 0; --i) {
      LL tens = pow_(10, i);
      LL s = (x / tens + 1) * tens;
      for (int j = 1; j <= d; ++j) {
        LL tens2 = pow_(10, j);
        LL candidate = (s / tens2 + 1) * tens2 - 1;
        double tmp = avg(candidate);
        if (tmp < minr) {
          minr = tmp;
          ret = candidate;
        }
      }
    }
    return ret;
  }

  double avg(LL x) {
    double den = 0, num = x;
    while (x > 0) {
      den += x % 10;
      x /= 10;
    }
    DBG(num, num / den)
    return num / den;
  }
  long long pow_(long long a, long long n) {
    long long i = 1, ret = 1, p = a;
    while (i <= n) {
      if (i & n) ret *= p;
      i = (i << 1);
      p *= p;
    }
    return ret;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  string str;
  in(str);
  vector<int> cnt(26,0);
  foreach(i,str){
    ++cnt[i-'a'];
  }
  ll ans = 1;
  foreach(i,cnt)(ans*=i+1)%=MOD;
  (ans+=MOD-1)%=MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n; double bx, by; pair<double, double> p[100009];
int main() {
	scanf("%d", &n);
	double sq = sin(1.234), cq = cos(1.234);
	for(int i = 0; i < n; i++) {
		scanf("%lf%lf", &bx, &by);
		double ex = bx * cq - by * sq;
		double ey = bx * sq + by * cq;
		p[i] = make_pair(ex, ey);
	}
	sort(p, p + n);
	double ret = 1.0e+10;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n && p[j].first - p[i].first <= ret; j++) {
			double dist = hypot(p[i].first - p[j].first, p[i].second - p[j].second);
			if(ret > dist) ret = dist;
		}
	}
	printf("%.15lf\n", ret);
	return 0;
}

Measured memory_bytes: 4840
#define ll long long
#define ffor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  int array[512345];
  int a[212345];

  rep(i, n) scanf("%d", &a[i]);
  int left = 212345, right = left + 1;
  rep(i, n) {
    if (i % 2 == (n - 1) % 2)
      array[left--] = a[i];
    else
      array[right++] = a[i];
  }
  for (int i = left + 1; i < right; i++) printf("%d ", array[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>

#define fst first
#define snd second

using namespace std;

typedef pair<int,int> pp;
vector<int> G[105000];
int dis[105000];
int S[105000];

int main(void) {
    int n,m,s,t;
    scanf("%d%d%d%d",&n,&m,&s,&t);
    s--, t--;
    memset(dis, 0x20, sizeof(dis));
    for(int i=0; i<m; i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    {
        priority_queue<pp> q;
        q.push(pp(-0, s));

        while(!q.empty()) {
            pp t = q.top(); q.pop();
            int d = -t.fst, x = t.snd;

            if(dis[x] != 0x20202020) continue;
            dis[x] = d;
            S[d]++;

            for(int y : G[x])
                if(dis[y] == 0x20202020)
                    q.push(pp(-(d+1), y));
        }
    }

    int old = dis[t];
    memset(dis, 0x20, sizeof(dis));

    long long int res=0;
    {
        priority_queue<pp> q;
        q.push(pp(-0, t));

        while(!q.empty()) {
            pp t = q.top(); q.pop();
            int d = -t.fst, x = t.snd;

            if(dis[x] != 0x20202020) continue;
            dis[x] = d;

            if(old-2-d >= 0)
                res += S[old-2-d];

            for(int y : G[x])
                if(dis[y] == 0x20202020)
                    q.push(pp(-(d+1), y));
        }
    }

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

}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  
        int h,w;cin>>h>>w;
        int ans=0;
        int n;cin>>n;
        ans=n/h;
        if(n%h) ans++;
        int t2=0;
        t2=n/w;
        if(n%w) t2++;
        cout<<min(t2,ans);

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


mod = 10 ** 9 + 7
comb = Combination(2 * 10 ** 6 + 10, mod)

K = int(input())
S = input()
N = len(S)

ans = 0
for i in range(K + 1):
    res = K - i
    right = pow(26, res, mod)
    pos = comb(N - 1 + i, i)
    cnt = pow(25, i, mod)
    tmp = right * pos % mod * cnt % mod
    ans = (ans + tmp) % mod
print(ans)

Measured memory_bytes: 117592
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

vector<int> G[N];
map<pair<int,int>, int> ans;
int max_color;
bool checked[N];

void saiki(int now, int parent_color){
  checked[now] = true;
  int color = 1;
  if(parent_color == 1){
    color++;
  }

  rep(i,G[now].size()){
    int next = G[now][i];
    if(checked[next]) continue;
    ans[{min(now,next), max(now,next)}] = color;
    chmax(max_color, color);
    saiki(next, color);
    color++;
    if(parent_color == color){
      color++;
    }
  }
}

int main(void){
  int n;cin>>n;
  vector<pair<int,int>> edge;
  rep(i,n-1){
    int a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    edge.push_back({a,b});
  }

  rep(i,n){
    checked[i] = false;
  }
  max_color = 0;

  saiki(0, 0);
  cout<<max_color<<endl;
  rep(i,n-1){
    cout<<ans[edge[i]]<<endl;
  }

  return 0;
}


Measured memory_bytes: 18808