akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

struct City {
    int pref, year, id;
};

int32_t main() {
    // fastIO();
    
    int n, m, tok = 0;
    scanf("%lld %lld", &n, &m);
    
    vector<City> cities(m);
    for (auto &x : cities) scanf("%lld %lld", &x.pref, &x.year), x.id = tok++;
    sort(ALL(cities), [](auto a, auto b) {
        if (a.pref != b.pref) return a.pref < b.pref;
        return a.year < b.year;
    });
    
    char ans[m][15];
    for (int i = 0; i < m; ++i) {
        if (!i or cities[i].pref != cities[i-1].pref) tok = 0;
        sprintf(ans[cities[i].id], "%06d%06d", cities[i].pref, ++tok);
    }
    
    for (int i = 0; i < m; ++i) puts(ans[i]);
    
    return 0;
}

Measured memory_bytes: 5376
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


const ll MAX_N = 1000000010;

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

  vector<ll> v;
  ll num = 1;
  while (num * num < MAX_N) {
    v.push_back(num * num);
    num++;
  }

  reverse(v.begin(), v.end());

  for (auto sq : v) {
    if (sq <= n) {
      cout << sq << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3760
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val warshall_floyd :
    (* 頂点の数n *)
    int ->
    (* 辺のリスト *)
    (* 頂点は0からn-1までの整数でなくてはならない *)
    (int * int * Weight.t) church_list ->
    (* 辿り着けなければinf，負閉路を含む経路があればneg_infを返す関数 *)
    (int -> int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let warshall_floyd n es =
    let d = Array.make_matrix n n Weight.inf in
    for v = 0 to n - 1 do
      d.(v).(v) <- Weight.zero
    done;
    es.fold (fun (u, v, c) () ->
      (* c < d.(u).(v) *)
      if 0 < Weight.compare d.(u).(v) c
      then d.(u).(v) <- c) ();
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
        for k = 0 to n - 1 do
          let open Weight in
          if 
            (* 経路がない場合は更新しない *)
            0 < Weight.compare inf d.(j).(i)
            && 0 < Weight.compare inf d.(i).(k)
            (* d.(j).(i) + d.(i).(k) < d.(j).(k) *)
            && 0 < Weight.compare d.(j).(k) (d.(j).(i) + d.(i).(k))
          then d.(j).(k) <- d.(j).(i) + d.(i).(k)
        done
      done
    done;
    for i = 0 to n - 1 do
      (* 頂点iを通る負閉路がある *)
      if 0 < Weight.compare Weight.zero d.(i).(i) then
        for j = 0 to n - 1 do
          for k = 0 to n - 1 do
            (* 負閉路を通る経路があれば，最短距離を負の無限大で更新 *)
            let open Weight in
            if 0 < Weight.compare inf d.(j).(i) && 0 < Weight.compare inf d.(i).(k)
            then d.(j).(k) <- Weight.neg_inf
          done
        done
    done;
    fun u v -> try d.(u).(v) with _ -> Weight.inf
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let inf = max_int
  let neg_inf = min_int
  let compare = compare
end)

let perm k xs =
  let rec perm_aux trace n k i xs ys acc =
    match k, i, xs with
    | 0, _, _ -> trace :: acc
    | _, 0, _ -> acc
    | _, _, [] -> perm_aux trace n k i (List.rev ys) [] acc
    | _, _, x :: xs ->
        perm_aux trace n k (i - 1) xs (x :: ys) @@
        perm_aux (x :: trace) (n - 1) (k - 1) (n - 1) xs ys acc in
  let n = List.length xs in
  perm_aux [] n k n xs [] []

let () = Scanf.scanf "%d %d %d\n" @@ fun n m r ->
  let rs = Array.init r @@ fun _ -> Scanf.scanf "%d " pred in
  let abcs = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c in
  let d = G.warshall_floyd n { G.fold = fun f -> Array.fold_right (fun ((a, b, c) as e) acc -> f (b, a, c) @@ f e acc) abcs } in
  Printf.printf "%d\n" @@
  List.fold_left (fun acc (r :: rs) ->
    min acc @@
    snd @@
    List.fold_left (fun (r, a) s -> (s, d r s + a)) (r, 0) rs) max_int @@
  perm r @@
  Array.to_list rs


Measured memory_bytes: 6784
/*
 * I won't be broken
 * I won't be tortured
 * I won't be beaten down
 * I have the answer
 * I can take the pressure
 * I will turn it all around
 * Lift me up above this
 * The flames and the ashes
 * Lift me up and help me to fly away
*/
#include <bits/stdc++.h>
using namespace std;
bool is(int x){
	int f = x/100;
	int s = (x%100)/10;
	int t = x%10;
	return s==t&&f==t;
}
int n;
int main(){
	scanf("%d",&n);
	for(int  i= n; i<=999; i++){
		if(is(i)){
			printf("%d\n",i);
			break;
		}

	}
        return 0;
}




Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            data = []
            for i in range(n):
                line = raw_input()
                l = line.split()[0]
                p, a, b, c, d, e, f, s, m = map(int, line.split()[1:])
                efficiency = 1.0 * (f * s * m - p) / (a + b + c + m * (d + e))
                data.append((efficiency, l))
            data.sort(key=lambda x: (-x[0], x[1]))
            for d in data:
                print d[1]
            print '#' 
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4708
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define rep1(i,N) for(int i=1;i<=(int)(N);i++)
#define fs first
#define sc second
#define eb emplace_back
#define pb eb
#define all(x) x.begin(),x.end()
template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    V<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i]; a[i]--;
    }

    for (int i = 0; i < n; i++) {
        if (a[i] > i) {
            cout << -1 << endl;
            return 0;
        }
    }

    V<int> res;

    for (int ph = 0; ph < n; ++ph) {
        for (int i = n - 1 - ph; i >= 0; i--) {
            if (a[i] == i) {
                res.push_back(i);
                a.erase(a.begin() + i);
                break;
            }
        }
        show(a);
    }

    reverse(res.begin(), res.end());

    for (int d: res) cout << d + 1 << endl;
    return 0;
}


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

int main() {
	// your code goes here
	long long n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	sort(arr,arr+n);
	long long ans=arr[n-1];
	int f=0;
	int i=n-1;
	int counter=n-2;
	while(counter>0){
		if(f==0) i--;
		ans+=arr[i];
		f=!f;
		counter--;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4412
n=int(input())
a=[int(x) for x in input().split()]
flag=True;
for x in a:
    if x%2==0:
        if x%3==0 or x%5==0:
            pass
        else:
            flag=False
            break
if flag==False:
    print("DENIED")
else:
    print("APPROVED")
            


Measured memory_bytes: 2940
str = input()
ans = []
allow = ["A","C","G","T"]
count = 0
for s in str:
  if s in allow:
    count = count + 1
    ans.append(count)
  else:
    count = 0
    
if len(ans) == 0:
  print(0)
else:
  print(sorted(ans)[-1])

Measured memory_bytes: 3060
/*
USER:
TASK:
ALGO:
*/
/*
#pragma warning (disable: 4786)
#pragma comment (linker, "/STACK:0x800000")
*/
/*#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>*/
#include<bits/stdc++.h>

#define INF_MAX     2147483647
#define INF_MIN     -2147483648
#define INF         (1 << 30)
#define EPS         1e-9
#define N           2 + 1000000
#define MOD         10000000007
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define Pi acos(-1.0)
#define MP(x, y) make_pair(x, y)
#define REV(s, e) reverse(s, e)
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define CPY(d, s) memcpy(d, s, sizeof(s))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define SZ(c) (int)c.size()
#define PB(x) push_back(x)
#define ff first
#define ss second
#define i64 long long
#define ld long double
#define pii pair< int, int >
#define psi pair< string, int >
#define ALL(c) (c).begin(),(c).end()
#define REP(i, n) for(int i=0; i<(int)n; ++i)
#define rep(i,a,b)  for(int i=(a); i<(b); i++)
#define repC(i,x)   for(size_t i=0; i<x.size(); i++)
#define FOR(i, c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
using namespace std;

template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }
template< class T > T _min(T a, T b) { return (a < b ? a : b); }
template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template <class T> string toStr(const T &x)
{ stringstream s; s << x; return s.str(); }

template <class T> int toInt(const T &x)
{ stringstream s; s << x; int r; s >> r; return r; }

template<class T> string itoa(T a)
{
    if(!a) return "0";
    string ret;
    for(T i=a; i>0; i=i/10) ret.PB((i%10)+48);
    reverse(ALL(ret));
    return ret;
}
#define on(n,pos) (n | (1LL<<(pos)))
#define off(n,pos) n & ~(1LL<<pos)
#define isOn(n,pos) (bool)(n & (1LL<<(pos)))

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

    int a, b, gcd = 0;

    while(cin>>a>>b)
    {
        for(int i = 1; i <= a && i <= b; i++)
        {
            if(a % i == 0 && b % i == 0)
            {
                gcd = i;
            }
        }
        cout<<gcd<<endl;
        gcd = 0;
    }
    return 0;
}

Measured memory_bytes: 1192
package main

import (
	"fmt"
)

func main() {
	var (
		s string
		i int
	)
	fmt.Scanln(&s)
	if s[0] == '1' {
		i++
	}
	if s[1] == '1' {
		i++
	}
	if s[2] == '1' {
		i++
	}
	fmt.Println(i)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int64_t DP[51][51][2510]; // i個目までの中から、j個選んだ時に、合計がkになる数

void init()
{
  for (int i = 0; i <= 50; i++)
  {
    for (int j = 0; j <= 50; j++)
    {
      for (int k = 0; k <= 2500; k++)
      {
        DP[i][j][k] = 0;
      }
    }
  }
}

int main()
{
  int64_t N, A, ans = 0;
  cin >> N >> A;
  init();
  DP[0][0][0] = 1;
  vector<int64_t> X(N + 1, 0);
  for (int i = 1; i <= N; i++)
    cin >> X.at(i);
  for (int i = 1; i <= N; i++) // 全部でi個
  {
    for (int j = 0; j <= i; j++) // i個から選ぶ数がj個
    {
      for (int k = 0; k <= 2500; k++)
      {
        if (j >= 1 && k >= X.at(i))
          DP[i][j][k] = DP[i - 1][j - 1][k - X.at(i)] + DP[i - 1][j][k];
        else
          DP[i][j][k] = DP[i - 1][j][k];
      }
    }
  }
  for (int j = 1; j <= N; j++)
    ans += DP[N][j][A * j];
  cout << ans << endl;
}


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

double dist(vector<int>& x1, vector<int>& x2)
{
    double d = 0;
    for (int i = 0; i < x1.size(); i++) {
        d += (x1[i] - x2[i]) * (x1[i] - x2[i]);
    }
    return sqrt(d);
}

int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            double di = dist(x[i], x[j]);
            if (di == (int)di) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

ll H, W;

int main() {
  cin >> H >> W;

  ll ans = INF;
  repe(i, 1, H - 1) {
    ll p1 = i * W;

    ll rh = H - i;
    if (rh % 2 == 0 || W % 2 == 0) {
      ll p2 = rh * W / 2;
      chmin(ans, abs(p1 - p2));
    } else {
      if (rh > W) {
        ll p2 = rh / 2 * W;
        ll p3 = rh * W - p2;
        ll ma = max(p1, max(p2, p3));
        ll mi = min(p1, min(p2, p3));
        chmin(ans, ma - mi);
      } else {
        ll p2 = W / 2 * rh;
        ll p3 = rh * W - p2;
        ll ma = max(p1, max(p2, p3));
        ll mi = min(p1, min(p2, p3));
        chmin(ans, ma - mi);
      }
    }
  }

  repe(i, 1, W - 1) {
    ll p1 = i * H;

    ll rw = W - i;
    if (rw % 2 == 0 || H % 2 == 0) {
      ll p2 = rw * H / 2;
      chmin(ans, abs(p1 - p2));
    } else {
      if (rw > H) {
        ll p2 = rw / 2 * H;
        ll p3 = rw * H - p2;
        ll ma = max(p1, max(p2, p3));
        ll mi = min(p1, min(p2, p3));
        chmin(ans, ma - mi);
      } else {
        ll p2 = H / 2 * rw;
        ll p3 = rw * H - p2;
        ll ma = max(p1, max(p2, p3));
        ll mi = min(p1, min(p2, p3));
        chmin(ans, ma - mi);
      }
    }
  }

  cout << ans;
}


Measured memory_bytes: 3616
<?php

$S = trim(fgets(STDIN));

if($S[0]!='A' || ctype_upper($S[1]) || ctype_upper($S[strlen($S)-1])){
    echo 'WA';
    exit;
}

$ok = false;
for($i=2;$i<strlen($S);$i++) {
    if(!$ok && $S[$i] == 'C'){
        $ok = true;
        continue;
    }
    if(ctype_upper($S[$i])) {
        echo 'WA';
        exit;
    }
}

echo $ok ? 'AC' : 'WA';

Measured memory_bytes: 4604
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n;

int a[N_MAX];

int cnt[N_MAX];

int mx;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        mx = max(mx, a[i]);
        cnt[a[i]]++;
    }
    if(cnt[mx] == n)
    {
        if(mx * 2 <= n || mx == n - 1)
            cout << "Yes\n";
        else
            cout << "No\n";
        return 0;
    }
    int c = cnt[mx - 1];
    int cntMi = c + (c < n);
    int cntMx = c + (n - c) / 2;
    if(cntMi - 1 <= mx - 1 && mx - 1 <= cntMx - 1)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
const unsigned long long mod=1e9+7;
unsigned long long a[maxn];
unsigned long long quick_pow(unsigned long long a,int b)
{
	unsigned long long res=1;
	while(b)
	{
		if(b&1)
			(res*=a)%=mod;
		(a*=a)%=mod;
		b>>=1;
	}
	return res;
}
bool ejz[maxn][64];
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
	ios::sync_with_stdio(0);
//  fl();
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		unsigned long long tmp=a[i];
		for(int j=0;j<=60;j++)
		{
			ejz[i][j]=tmp%2;
			tmp/=2;
		}
	}
	unsigned long long ans=0;
	for(int i=0;i<=60;i++)
	{
		unsigned long long zero=0,one=0;
		for(int j=1;j<=n;j++)
		{
			if(ejz[j][i]==0)
				zero++;
			else 
				one++;
		}
		unsigned long long val=quick_pow(2,i)%mod;
		unsigned long long num=zero*one%mod;
		(ans+=num*val%mod)%=mod;
	}
	cout<<ans<<endl;
	return 0;
}



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

#define HIT 1
#define HR 2
#define OUT 3

int main(void){
    int outCnt, pt;
    int runner; // use bits
    char event[8];
    int eventID;
    int n;
    bool endInning;
    
    scanf("%d", &n);    
    for (int i=0; i<n; i++){
        endInning = false;
        outCnt = runner = pt = 0;
        while (!endInning){
            scanf("%s", event);
            if (event[0]=='O') eventID=OUT;
            else if (event[1]=='I') eventID=HIT;
            else eventID=HR;
            switch (eventID){
            case HIT:
                if (runner & 0x4) pt++;
                runner = (runner<<1) & 0x7;
                runner |= 0x1;
                break;
            case HR:
                pt++;
                if (runner & 0x4) pt++;
                if (runner & 0x2) pt++;
                if (runner & 0x1) pt++;
                runner = 0;
                break;
            case OUT:
                if (++outCnt == 3) endInning = true;
                break;
            }
        }
        printf("%d\n",pt);
    }
    
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
l = list(map(int, input().split()))
a = sum(l)

min_s = float('inf')
x = 0
for i in range(n-1):
  x += l[i]
  s = abs(a-2*x)
  if s <= min_s:
    min_s = s
print(min_s)

Measured memory_bytes: 24832
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

const int N = 1<<18;
int a[N][2];

int main() {
	int n;
	cin >> n;
	REP(i, 1 << n)scanf("%d", &a[i][0]);
	REP(i, n) {
		REP(j, 1 << n) {
			if ((j & (1 << i))) {
				auto tmp = VI{ a[j][0], a[j][1], a[j ^ (1 << i)][0], a[j ^ (1 << i)][1] };
				SORT(tmp);
				a[j][0] = tmp[3];
				a[j][1] = tmp[2];
			}
		}
	}
	int ret = -1;
	FOR(i, 1, 1 << n) {
		ret = max(ret, a[i][0] + a[i][1]);
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 5120
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(string, A, N);
    vi D = {2, 5};
    vvi f(2, vi(N));
    vvi g(20, vi(20));
    REP(i, N)
    {
        string x;
        string y;
        ll j;
        for (j = 0; j < A[i].size() and A[i][j] != '.'; ++j)
        {
            x.push_back(A[i][j]);
        }
        ++j;
        for (; j < A[i].size(); ++j)
        {
            y.push_back(A[i][j]);
        }
        while (y.size() < 9)
        {
            y.push_back('0');
        }
        ll p = stoll(x + y);
        REP(k, 2)
        {
            f[k][i] = -9;
            while (p % D[k] == 0)
            {
                ++f[k][i];
                p /= D[k];
            }
            CH(min, f[k][i], 9LL);
        }
        ++g[f[0][i] + 9][f[1][i] + 9];
    }
    ll ans = 0;
    REP(i, N)
    {
        for (ll j = -f[0][i]; j <= 9; ++j)
        {
            for (ll k = -f[1][i]; k <= 9; ++k)
            {
                ans += g[j + 9][k + 9];
            }
        }
        ans -= f[0][i] >= 0 and f[1][i] >= 0;
    }
    ans /= 2;
    OUT(ans);
}

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

typedef long long ll;

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

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

    vector<ll> sum(n+1);
    sum[0] = 0;
    for(int i = 1; i <= n; i++){
        sum[i] = sum[i-1] + a[i];
    }

    int t = 0;
    for(int i = 1; i < n; i++){
        if(2*sum[i] < a[i+1])   t = i;
    }

    cout << n-t << endl;

    return 0;
}

Measured memory_bytes: 1792
//#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
// using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  vl A;
  cin >> N;
  cout << ((N + 1) % 2) << endl;

  return 0;
}


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e2 + 5;

int dp[maxn][maxn] , n , a[maxn];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    fill_n(&dp[0][0],maxn*maxn,1e9);
    dp[0][0] = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        for(int j = a[i] ; j >= 0 ; --j)
        {
            dp[i][j] = dp[i][j + 1];
            for(int t = 0 ; t <= j ; ++t)
            {
                dp[i][j] = min(dp[i][j] , dp[i - 1][t] + a[i] - t);
            }
//            cout << dp[i][j] << " \n"[j == 0];
        }
    }
    cout << dp[n][0];
}


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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;

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

  ll k;
  cin >> k;
  queue < ll > q;
  ll x;
  for(int i = 1; i < 10; i++) q.push(i);
  for(int i = 1; i <= k; i++){
    x = q.front(); q.pop();
    if(x % 10 != 0) q.push(10 * x + (x % 10) - 1);
    q.push(10 * x + (x % 10));
    if(x % 10 != 9) q.push(10 * x + (x % 10) + 1);
  }

  cout << x << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll a,b; cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3504
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
    ll a,b;
    cin>>a>>b;
    cout << max(0LL,a-2*b) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

N = int(input())
# white: 0, black: 1
g = [[] for _ in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    g[u-1].append((v-1, w))
    g[v-1].append((u-1, w))
 
visited = [False]*N
def dfs(num, kyori): # 始点からの距離
    if not visited[num]:
        visited[num] = '1' if kyori%2 == 1 else '0'
        for hen in g[num]:
            dfs(hen[0], kyori+hen[1])
    return visited
 
print('\n'.join(dfs(0,0)))

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

int main(){
    int N;
    cin >> N;
    set<char> hina_arares;
    for(int i = 0; i < N; i++){
        char hina_arare;
        cin >> hina_arare;
        hina_arares.insert(hina_arare);
    }
    if(hina_arares.size() == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void){
	int dice[6];
	int i,j=0;
	char c;
	char throw[100];
	int top, front, right, tmp;

	for(i=0; i<6; i++){
		scanf("%d", &dice[i]);
	}
	top =1;
	front =2;
	right = 3;
	scanf("%s", throw);
	while(throw[j] != '\0'){
		//printf("i=%d %c\n",i, c);
		switch (throw[j]) {
			case 'S':
				tmp = top;
				top = 7-front;
				front = tmp;
				break;
			case 'N':
				tmp = top;
				top = front;
				front = 7-tmp;
				break;
			case 'E':
				tmp = top;
				top = 7-right;
				right = tmp;
				break;
			case 'W':
				tmp = top;
				top = right;
				right = 7-tmp;
				break;
			default:
				break;
		}
		j++;
	}
	printf("%d\n", dice[top-1]);
	return 0;
}

Measured memory_bytes: 596
n = int(input())
p = list(map(int, input().split()))
cn = 0
for i in range(n - 2):
    if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]):
        cn = cn + 1
        
print(cn)

Measured memory_bytes: 61828
/*He who forgives and acknowledges himself... that is what it truly means to be strong!*/
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <list>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <climits>
#include <utility>
#include <ctime>
#include <tuple>
#include <fstream>
#define T int test_case; scanf("%d",&test_case); while(test_case--)
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pc(x) printf("%c",x)
#define pi(x) printf("%d\n",x)
#define pd(x) cout.precision(10),cout<<fixed<<x<<endl;
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define in insert
#define er erase
#define pii pair<int, int>
#define plll pair<long long, long long>
#define tr(x,it) for(auto it : x)
#define INF 1ll<<60
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230
#define bs(x,lo,hi,mid) cout<<x<<" "<<lo<<" "<<hi<<" "<<mid<<endl;
using namespace std;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n&1) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<int> prime;
bool primee[10000000];
void primegen(ll x) { for(ll i=2;i*i<=x;i++) if(!primee[i]) for(ll j=i*i;j<=x;j+=i) primee[j]=true; for(ll i=2;i<=x;i++) if(!primee[i]) prime.push_back(i);}

map<ll,int> m,ma;
ll c[55];

ll C(ll x,ll y)
{
	ll p=1;
	y=max(y,x-y);
	map<ll,int> mu;
	for(ll i=x;i>y;i--)
	{
		p=p*i;
		for(ll j=x-y;j>=2;j--)
			if(mu[j]==0 && p%j==0)
			{
				mu[j]=1;
				p=p/j;
			}
	}
	return p;	
}
int main()
{
   int i,j;
   int n,a,b;
   si(n);
   si(a);
   si(b);
   ll x;
   FOR(i,0,n)
   	sll(c[i]),m[c[i]]++;
   sort(c,c+n);
  	long double mx=0;
  	FOR(i,a,b+1)
  	{
  		j=n-1;
  		int x=i;
  		long double tmp=0;
  		while(x>0)
  		{
  			tmp+=c[j];
  			x--;
  			j--;
  		}
  		mx=max(mx,tmp/i);
  	}
  	cout.precision(10);
  	cout<<fixed<<mx<<endl;
  	ll ans=0;
  	FOR(i,a,b+1)
  	{
  		j=n-1;
  		int x=i;
  		ma.clear();
  		long double tmp=0;
  		while(j>=n-i)
  		{
  			tmp+=c[j];
  			ma[c[j]]++;
  			j--;
  		}
  		tmp=tmp/i;
  		ll p=1;
  		if(tmp==mx)
  		{
  			tr(ma,it)
  			{
  				// cout<<i<<" "<<it.fr<<" "<<m[it.fr]<<" "<<ma[it.fr]<<endl;
  				p=p*C(m[it.fr],ma[it.fr]);
  			}
  			ans+=p;
  		}
  	}
  	pll(ans);
   return 0;
}


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

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

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

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

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

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

} // namespace n91

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

namespace n91 {

void main_() {
  u32 x, a;
  std::cin >> x >> a;
  if (x < a) {
    std::cout << "0" << std::endl;
  } else {
    std::cout << "10" << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   int n;
   cin >> n;
   if(n>=400 && n<=599){
      cout << '8';
   }
   else if(n>=600 && n<=799){
    cout << '7';
   }
   else if(n>=800 && n<=999){
    cout << '6';
   }
   else if(n>=1000 && n<=1199){
    cout << '5';
   }
   else if(n>=1200 && n<=1399){
    cout << '4';
   }
   else if(n>=1400 && n<=1599){
    cout << '3';
   }
   else if(n>=1600 && n<=1799){
    cout << '2';
   }
   else if(n>=1800 && n<=1999){
    cout << '1';
   }
   
}


Measured memory_bytes: 3632
N = int(input())
ad = {}
status = {}
edge=[]

for n in range(N):
    ad[n+1]=set([])
    status[n+1] = -1
    
for n in range(N-1):
    a,b = list(map(int,input().split()))
    edge.append((a,b))
    ad[a].add(b)
    ad[b].add(a)
    
color = set([])
parent = [0] * (N+1) 
ans={}

#BFS
from collections import deque

start = 1
status[start] = 0
que = deque([start])

while len(que) > 0:
    start = que[0]
#     print(start,parent[start])
    c = 1
    for v in ad[start]:
        if status[v] == -1:
            que.append(v)
            status[v]=0
            if parent[start] == c:
                c += 1
            parent[v] = c
            color.add(c)
            
            s = min(start,v)
            e = max(start,v)
            
            ans[s,e]=c
            
            c+=1
            
#     print(parent,que)
    que.popleft()

print(len(color))
for e in edge:
    print(ans[e])

Measured memory_bytes: 137720
#include <cstdio>
#include <numeric>
#include <cmath>
#include <iostream>
using namespace std;

const int maxn = 300;
double dp[3 * maxn + 1][2 * maxn][maxn + 1] = {0};
int occur[3] = {0};

void test() {
  double sum = 0;
  double n = 50, e = 30;
  for (double i = 0; i <= 1000; i++) {
    sum += (n - e) / n * pow(e / n, i) * (i + 1);
  }
  cout << sum << endl;
  cout << e / (n - e) << endl;
  cout << n / (n - e) << endl;
}

int main() {
  // test();
  // return 0;
  int n;
  cin >> n;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    occur[x - 1]++;
  }
  for (int k = 0; k <= occur[2]; k++) {
    for (int j = 0; j <= occur[1] + occur[2]; j++) {
      for (int i = 0; i <= occur[0] + occur[1] + occur[2]; i++) {
        if (i == 0 && j == 0 && k == 0) continue;
        double s = i + j + k;
        dp[i][j][k] = 
          (k ? dp[i][j + 1][k - 1] * k / s : 0) +
          (j ? dp[i + 1][j - 1][k] * j / s : 0) + 
          (i ? dp[i - 1][j][k] * i / s : 0) + 
          + n / s;
          
      }
    }
  }
  cout.precision(10);
  cout << dp[occur[0]][occur[1]][occur[2]]  << '\n';
}


Measured memory_bytes: 425472
#include<stdio.h>
int main()
{
    int a,b,c,d,i=1;
	
	scanf("%d %d",&a, &b);
	
while(a>=b){
      c=a%b;
  d=a-c;
      a=d/b;
		i++;
	}
  
	printf("%d \n", i);
	    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int h,w,k;
	cin>>h>>w>>k;
	int c[h][w];
	char ch;
	rep(i,h){
		rep(j,w){
			cin>>ch;
			if(ch=='#')c[i][j]=1;
			else c[i][j]=0;
		}
	}

	int ans=0,count=0;
	int y[h],x[w];
	for(int bit1 = 0;bit1 < (1<<h);++bit1){
		rep(i,h)y[i]=0;
		for(int i=0;i<h;++i){
			if(bit1 & (1<<i))y[i]=1;
		}
		for(int bit2 = 0;bit2 < (1<<w);++bit2){
			count=0;
			rep(i,w)x[i]=0;
			for(int i=0;i<w;++i){
				if(bit2 & (1<<i))x[i]=1;
			}
			//探索開始
			rep(i,h){
				rep(j,w){
					if(y[i]==0 && x[j]==0 && c[i][j]==1){
						count++;
					}
				}
			}
			if(count==k)ans++;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#define chmax(p,q)(p<(q)?p=(q),1:0)
char s[500010];
int a[500010];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	long long ans=0;
	for(int i=0;i<n;i++)if(s[i  ]=='<')chmax(a[i+1],a[i]+1);
	for(int i=n;i>0;i--)if(s[i-1]=='>')chmax(a[i-1],a[i]+1);
	for(int i=0;i<=n;i++)ans+=a[i];
	printf("%lld",ans);
}

Measured memory_bytes: 2560
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    int now = 0;
    rep(i, n) {
        if (i == 0) {
            if (a[i] != 0) {
                puts("-1");
                return 0;
            } else continue;
        }
        if (a[i] == 0) {
            now = 0;
        } else if (a[i] == 1) {
            now = 1;
            ans++;
        } else {
            if (a[i-1] + 1 == a[i]) {
                now++;
                ans++;
                continue;
            } else if (a[i-1] + 1 < a[i]) {
                puts("-1");
                return 0;
            } else {
                if (now < a[i]) {
                    puts("-1");
                    return 0;
                } else {
                    now++;
                    ans += a[i];
                }
                
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

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

#define lim5 100002
#define lim9 1000000002

int main(){
	in(n);
	int d[50] = {}, sum = 0;
	rep(i, n) cin >> d[i];

	rep(i, n){
		for(int j = i+1; j < n; j++){
			sum += d[i] * d[j];
		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define For(i, a, n) for (ll (i) = (a); (i) < (n); (i)++)
#define prl(x) cout << (x) << endl
#define pr(x) cout << (x)
#define all(v) (v).begin(), (v).end()

int main(void){
    string s,t;map<char,vl> c;
    cin>>s>>t;ll n=s.length(),m=t.length(),cur=0;
    rep(i,n) c[s[i]].push_back(i);
    rep(i,m) if(!c[t[i]].size()){prl(-1);return 0;}
    for(char a:t){
        vl& v=c[a]; auto it=lower_bound(all(v),cur%n);
        (cur=cur/n*n+1)+=it==v.end()?*(v.begin())+n:*it;
    }
    prl(cur);
    return 0;
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int a = A%B;
    rep(i, B){
        if(a*i%B==C){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    string n;
    cin >> N;
    n = to_string(N);
    if (n[0] == n[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
main :: IO ()
main = do
  n <- readLn :: IO Int
  let count6 = map (count 6) [0..n]
      count9 = map (count 9) [n,n-1..0]
  print $ minimum $ zipWith (+) count6 count9


count :: Int -> Int -> Int
count unit money = let idx = ceiling $ logBase (fromIntegral unit) $ fromIntegral money
                   in  go (map (unit^) [idx,idx-1..0]) money 0
  where go _ 0 c      = c
        go (x:xs) m c = go xs (m`mod`x) (c + m`div`x)


Measured memory_bytes: 5164
#include<cstdio>
using namespace std;
#define N 3005
#define mod 1000000007
#define inv 500000004
int n,dp[N][N],v[N],q,a,b;
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)dp[i][j]=(v[i]<v[j]);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&a,&b);
		int tp=dp[a][b]+dp[b][a];
		for(int j=1;j<=n;j++)
		{
			dp[j][a]=dp[j][b]=1ll*(dp[j][a]+dp[j][b])*inv%mod;
			dp[a][j]=dp[b][j]=1ll*(dp[a][j]+dp[b][j])*inv%mod;
		}
		dp[a][b]=dp[b][a]=1ll*tp*inv%mod;
	}
	int as=0;
	for(int i=2;i<=n;i++)
	for(int j=1;j<i;j++)as=(as+dp[i][j])%mod;
	for(int i=1;i<=q;i++)as=as*2%mod;
	printf("%d\n",as);
}
//111222333

Measured memory_bytes: 35456