akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

const long long MOD = 1e9 + 7;

class BinomialCoefficients{
  int max;
  int mod;
  long long *fac;
  long long *finv;
  long long *inv;
public:
  long long C(int, int);
  BinomialCoefficients(int, int);
  ~BinomialCoefficients();
};
 
long long BinomialCoefficients::C(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
 
BinomialCoefficients::BinomialCoefficients(int mx = 1e7, int md = MOD){
  max = mx;
  mod = md;
  fac = new long long[max];
  finv = new long long[max];
  inv = new long long[max];
  
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < max; ++i){
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
 
BinomialCoefficients::~BinomialCoefficients(){
  delete [] fac;
  delete [] finv;
  delete [] inv;
}

int main(){
  long long X, Y;
  cin >> X >> Y;
  
  long long cnt = 1;
  if((2 * X - Y) % 3 != 0 || (2 * Y - X) % 3 != 0){
    cnt = 0;
  }
  
  long long x = (2 * Y - X) / 3;
  long long w = x + (2 * X - Y) / 3;
  
  BinomialCoefficients com(1e7, MOD);
  
  cout << com.C(w, x) * cnt << endl;
  
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int>P(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
    }
    vector<int>Q(N);
    for (int i = 0; i < N; ++i) {
        cin >> Q[i];
    }

    int ans = 0;
    int flag = 0;
    for (int i = 0; i < N; ++i) {
        if (P[i] == Q[i]) continue;
        if (P[i] > Q[i]) flag = 1;
        break;
    }

    if (flag == 0) {
        while (P != Q) {
            next_permutation(P.begin(), P.end());
            ans++;
        }
    } else {
        while (P != Q) {
            next_permutation(Q.begin(), Q.end());
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
	int m, nmax, nmin, n, a;
	while(1){
		n = 0;
		cin >> m >> nmin >> nmax;
		if(m == 0 && nmax == 0 && nmin == 0) break;
		int* p = new int[m];
		for(int i = 0; i < m; i++){
			cin >> p[i];
		}
		for(int j = nmin; j <= nmax; j++){
			if(n <= p[j-1] - p[j]){
				n = p[j-1] - p[j];
				a = j;
			}
		}
		cout << a << endl;
		delete[] p;
	}
	return 0;
}


Measured memory_bytes: 3076
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//-------------------------------Template--Above------------------------------------------------
string digs;
ll d;
ll dp[100001][105][2];
ll solve(ll pos,ll sum,ll tight)
{
	if(pos==digs.size())
	{
		if(sum%d==0) return 1;
		else return 0;
	}
	if(dp[pos][sum][tight]!=-1) return dp[pos][sum][tight];
	ll ans=0;
	if(tight==1)
	{
		ans=(ans+solve(pos+1,(sum+digs[pos]-'0')%d,1))%M;
		for(ll i=digs[pos]-1-'0';i>=0;i--)
		{
			ans=(ans+solve(pos+1,(sum+i)%d,0))%M;
		}
	}
	else
	{
		for(ll i=9;i>=0;i--)
		{
			ans=(ans+solve(pos+1,(sum+i)%d,0))%M;
		}
	}
	return dp[pos][sum][tight]=ans;
}

int main()
{
	boost
	cin>>digs;
	cin>>d;
	memset(dp,-1,sizeof(dp));
	cout<<(solve(0,0,1)-1+M)%M<<endl;
	return 0;
}


Measured memory_bytes: 165120
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<usize>();
    let K = read::<usize>();
    let mut v: Vec<i32> = Vec::new();

    for n in 0..N {
        let tmp = read::<i32>();
        v.push(tmp);
    }
    v.sort();
    v.reverse();
    let mut sum = 0;
    for k in 0..K {
        sum += v[k];
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,q;
    cin>>n>>q;
    int root[n+1],i;
    rep(i,n+1)
    	root[i]=i;
    for(i=1;i<=n-1;i++)
    {
    	int a,b;
    	cin>>a>>b;
    	root[b]=a;
    }

    
    int count[n+1];
   	rep(i,n+1)
   		count[i]=0;
    
    while(q--)
    {
    	int p,x;
    	cin>>p>>x;
    	count[p]+=x;
    }
   	
    for(i=1;i<=n;i++)
    {
    	if(root[i]!=i)
    		count[i]+=count[root[i]];
    	cout<<count[i]<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3968
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		int[][] matrix = new int[h][w];
		int odd = 0;
		for (int j = 0; j < h; j++) {
			for (int i = 0; i < w; i++) {
				int c = scanner.nextInt();
				matrix[j][i] = c;
				if (c % 2 == 1) {
					odd++;
				}
			}
		}
		int i = 0;
		int j = 0;
		int previ = 0;
		int prevj = 0;
		List<String> opeList = new ArrayList<String>();
		boolean isOpe = false;
		while (1 < odd) {
			int curVal = matrix[j][i];
			boolean isOdd = curVal % 2 == 1;

			// OPERATION
			if (isOpe && isOdd) {
				opeList.add((prevj+1) + " " + (previ+1) + " " + (j+1) + " " + (i+1));
				isOpe = false;
				odd -= 2;
			} else if (isOpe && !isOdd) {
				opeList.add((prevj+1) + " " + (previ+1) + " " + (j+1) + " " + (i+1));
			} else if (!isOpe && isOdd) {
				isOpe = true;
			}

			// MOVE
			previ = i;
			prevj = j;
			boolean moveRight = j % 2 == 0;
			if (moveRight) {
				if (i == w - 1) {
					j++;
				} else {
					i++;
				}
			} else {
				if (i == 0) {
					j++;
				} else {
					i--;
				}
			}
		}

		System.out.println(opeList.size());
		for (String ope : opeList) {
			System.out.println(ope);
		}
	}
}


Measured memory_bytes: 100776
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(i64, N, a, b, c, d, e);
    const i64 f = min({a, b, c, d, e});

    print((N + f - 1) / f + 4);

    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2941.cc: LISum
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], dp[MAX_N], ids[MAX_N], bs[MAX_N];

/* subroutines */

int lds(int n, int as[], int bs[]) { // longest decleasing sequence
  fill(dp, dp + n, -1);

  int m = 0;
  for (int i = 0; i < n; ++i) {
    ids[i] = lower_bound(dp, dp + n, as[i], greater<int>()) - dp;
    dp[ids[i]] = as[i];
    if (m < ids[i]) m = ids[i];
  }
  //for (int i = 0; i < n; i++) printf("%d ", ids[i]); putchar('\n');
  //for (int i = 0; i <= m; i++) printf("%d ", dp[i]); putchar('\n');

  int bn = m + 1;

  for (int i = n - 1; i >= 0; --i)
    if (ids[i] == m) bs[m--] = as[i];

  return bn;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = n - 1; i >= 0; i--) scanf("%d", as + i);

  int m = lds(n, as, bs);

  ll sum = 0;
  for (int i = 0; i < m; i++) sum += bs[i];
  printf("%lld\n", sum);

  //for (int i = 0; i < m; i++) printf("%d ", bs[i]); putchar('\n');
  return 0;
}



Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define fof(i,a,b) for(int i=a;i<=b;i++)
#define off(i,a,b) for(int i=a;i>=b;i--)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define stl(i,x) for(auto i=x.begin(); i!=x.end();i++)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
ll pw(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 1; i <= b; ++i)
        ans = (ans * a);
    return ans;
}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int cnt=0;
    fo(i,n)
    {
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

///Alhamdulillah


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

int build(LL n, deque<int> &ans) {
	if(n == 1) {
		ans.clear();
		return 1;
	}
	int res;
	if(n % 2) {
		ans.push_front(res = build(n - 1, ans));
	} else {
		ans.push_back(res = build(n/2, ans));
	}
	return res + 1;
}

vector<int> go(LL n) {
	vector<int> res;
	deque<int> temp;
	build(n + 1, temp);
	while(temp.size()) {
		res.push_back(temp.front());
		temp.pop_front();
	}
	return res;
}

int main() {
  ios_base::sync_with_stdio(false);
	LL n;
	cin >> n;
	vector<int> temp =  go(n);
	vector<int> ans(100, 0);
	for(int i = 0; i < 100; i++) {
		ans[i] = i + 1;
	}
	for(auto &elem: temp) ans.push_back(elem);
	assert(ans.size() <= 200);
	cout << ans.size() << '\n';
	for(auto &elem: ans) {
		cout << elem << ' ';
	}
	cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int n,m,d;cin>>n>>m>>d;
	double ans;
	if(d == 0) ans = 1. / n;
	else ans = 2.0 * (n - d) / n / n;
    cout.precision(10);
	cout<<fixed<<ans * (m - 1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll n,len = 1,sum = 26;
    cin>>n;
    while(true){
        if(sum >= n){
            break;
        }
        else{
            len++;
            sum +=pow(ll(26),len); 
        }
    }
    string ans = "";

    rep(i,len){
        ll tmp = n % 26 - 1;
        if(tmp < 0)tmp = 25;
        if(n%26 == 0)n--;
        n = n / 26;
        char ch = 'a' + tmp;
        ans  = ch + ans;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4060
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


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

	cout << a + a * a + a * a*a;
}

Measured memory_bytes: 3584
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define forn(i,a,b) for (int i = a; i <= b; i ++ )
#define mod(n,k) (((n%k)+k)%k)
using namespace std;
typedef long long ll;

ll T;
string x;
set < string > s;

int main()
{
    optimiza_io
    cin >> T;
    while( T -- ) {
        cin >> x;
        s.insert( x );
    }
    cout << s.size() << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 19212
N = int(input())
n_list = input().split(' ')
sort_list = []
t = 1
for num in n_list:
  if int(num) == t:
    sort_list.append(t)
    t += 1
if len(sort_list) == 0:
  print(-1)
else:
  print(N - len(sort_list))

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

int main(){
  string s;
  cin >> s;
  
  //vector<string> t;
  string t;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'B'){
      if(t.size() != 0){
        t.pop_back();
      }
    }
    else{
 	  t.push_back(s[i]);
    }
  }
  
  cout << t << endl;
}
  

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define N -1

typedef struct{ 
  int parent;
  int right,left;
}Record;
Record u[MAX];
int n,D[MAX],H[MAX];


void depth(int s, int p){
  if(s == N)return;
  D[s] = p;
  depth(u[s].left,p+1);
  depth(u[s].right,p+1);
}


int height(int s){
  int h1 = 0,h2 = 0;
  if(u[s].left != N){
    h1 = height(u[s].left) + 1;
  }
  if(u[s].right != N){
    h2 = height(u[s].right) + 1;
  }
  if(h1 > h2)H[s] = h1;
  else H[s] = h2;
  return H[s]; 
}


int Sibling(int s){
  if(u[s].parent == N)return N;

  if(u[u[s].parent].left != s && u[u[s].parent].left !=N){
    return u[u[s].parent].left;
  }
  if(u[u[s].parent].right != s && u[u[s].parent].right !=N){
    return u[u[s].parent].right;
  }
  return N;
}


void print(int s){
  int i,c;
  
  printf("node %d: ",s);
  printf("parent = %d, ",u[s].parent);
  printf("sibling = %d, ",Sibling(s));
  
  i = 0;
  if(u[s].left != N)i++;
  if(u[s].right != N)i++;
  printf("degree = %d, ",i);
  printf("depth = %d, ",D[s]);
  printf("height = %d, ",H[s]);
  
  if(u[s].parent == N)printf("root\n");
  else if(u[s].left == N && u[s].right ==N)printf("leaf\n");
  else printf("internal node\n");
}


int main(){
  int i,j,l,num,node,r,root=0;

  scanf("%d",&n);
  //Record[u]内の整数を初期化（必要なぶんだけ）
  for(i=0; i<n; i++) u[i].parent= N;
  //input
  for(i=0; i<n; i++){
    scanf("%d",&node);
    scanf("%d %d",&l,&r);
    u[node].left = l;
    u[node].right = r;
    if(l != N) u[l].parent = node;
    if(r != N) u[r].parent = node;
  }
  for(i=0; i<n ; i++){
    if(u[i].parent == N)root = i;//rootを見つけるため
  }
  
  depth(root,0);
  height(root);
  
  for(i=0; i<n; i++)print(i);
    
  return 0;
}



Measured memory_bytes: 2104
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
} 
  
/* Driver program to test above function */
int main() 
{ 
  string X,Y;
  cin >> X >> Y;
  int m = X.length(); 
  int n = Y.length(); 
  lcs(X, Y, m, n); 
  return 0; 
} 

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

int main() {
    string a , b ;
    cin >> a >> b ;
    int c = 0 ;
    for(int i = 0 ; i < 3 ; i ++)
        if(a[i] == b[i]) c ++ ;
    cout<<c<<endl ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int M=262144;
const ll mod=1e9+7;
int n;
vector<pair<int,ll> >v[M];
ll s[M],s2[M];
ll a[M];
bool done[M];
ll ans=0;
ll coo(ll p,ll t){
	return p*t%mod*((1+(p/2)*(t/2)%mod*p%mod*t%mod-p*(p/2)-t*(t/2))%mod)%mod;
}
void solve(ll p,ll t){
	ll cur=s[t]*s[t]-s2[t];
	cur=(cur%mod+mod)%mod;
	ll co=coo(p,t);
	co=(co+mod)%mod;
	ans=(ans+co*cur)%mod;
	done[t]=true;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=(1<<(n-1)); i<(1<<n) ;i++){
		cin >> a[i];
		a[i]+=(1<<(n-1))-1;
		ll p=i;
		ll r=1;
		for(int j=0; j<n ;j++){
			ll q=a[i];
			ll s=1;
			for(int k=0; k<n ;k++){
				v[p].push_back({q,r*s%mod});
				s=s*q%mod;
				q/=2;
			}
			r=r*p%mod;
			p/=2;
		}
	}
	for(int i=1; i<(1<<n) ;i++){
		for(auto c:v[i]){
			s[c.fi]=(s[c.fi]+c.se)%mod;
			s2[c.fi]=(s2[c.fi]+c.se*c.se)%mod;
		}
		for(auto c:v[i]){
			if(done[c.fi]) continue;
			solve(i,c.fi);
		}
		for(auto c:v[i]){
			done[c.fi]=false;
			s[c.fi]=s2[c.fi]=0;
			//g[c.fi].clear();
		}
	}
	ll half=(mod+1)/2;
	ans=ans*half%mod;
	cout << ans << '\n';
}

Measured memory_bytes: 955500
using System;
using System;
using System.Linq;

namespace AtCoderMake.ABC167
{
    class ABC167B
    {
        static void Main(string[] args)
        {
            var abck = Console.ReadLine().Split().Select((x) => long.Parse(x)).ToArray();
            long plus = 0;
            long minus = 0;
            plus = Math.Min(abck[0], abck[3]);
            minus = Math.Max(0, abck[3] - abck[0] - abck[1]);
            Console.WriteLine(plus-minus);
        }
    }
}


Measured memory_bytes: 28232
import java.util.*;
import java.lang.*;


public class Main {
    static int cmp[] = new int[10];
    static int d;
    static int g;
    static int p[];
    static int c[];
    static int min = 100000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        d = sc.nextInt();
        g = sc.nextInt();
        p = new int[d];
        c = new int[d];
        for (int i = 0; i < d; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        func(0);
        System.out.println(min);
    }
    static void func (int x) {
        if (x == d) {
            int sum = 0;
            int count = 0;
            for (int i = 0; i <= d - 1; i++) {
                sum += cmp[i] * (100 * (i + 1) * p[i]);
                sum += cmp[i] * c[i];
                count += cmp[i] * p[i];
            }
            for (int i = d - 1; i >= 0 && sum < g; i--) {
                if (cmp[i] == 0 && p[i] > 0) {
                    int v = 100 * (i + 1);
                    int num = Math.min(((g - sum + v-1) / v), p[i]);
                    sum += num*v;
                    count += num;
                }
            }
            if (sum >= g) {
                min = Math.min(min, count);
            }
            return;
        }
        cmp[x] = 1;
        func(x + 1);
        cmp[x] = 0;
        func(x + 1);
    }
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << x - a - ((x - a) / b) * b << endl;
  return 0;
}

Measured memory_bytes: 256
X = int(input())

if X >= 2000:
    print(1)

else:
    num = X // 100
    res = 0

    for a in range(num+1):
        for b in range(num-a+1):
            for c in range(num-(a+b)+1):
                for d in range(num-(a+b+c)+1):
                    for e in range(num-(a+b+c+d)+1):
                        for f in range(num-(a+b+c+d+e)+1):
                            if a*100 + b*101 + c*102 + d*103 + e*104 + f*105 == X:
                                res = 1
                                break

    print(res)
                            

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

#define ll   long long int
#define PI 3.14159265358979

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s, t;
    list<char>m_list;
    cin>>s;
    for(int i=0; i<s.length(); i++)
    {
        char b=s[i];
        if(b=='B')
        {
            if(!m_list.empty())
                m_list.pop_back();
        }
        else
            m_list.push_back(b);
    }

    for(auto i:m_list)
        cout<<i;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,a,b;
int h[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++)cin>>h[i];
  int l=1,r=1000000000,ans=r;
  while(l<=r){
    int mid=l+r>>1;
    int st=1;
    LL z=mid;
    for(int i=1;i<=n;i++){
      LL x=1ll*mid*b;
      if(x<h[i]){
        int y=(h[i]-x+(a-b)-1)/(a-b);
        z-=y;
      }
    }

    if(z>=0)ans=mid,r=mid-1;
    else l=mid+1;
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 4008
import Data.Array.Unboxed


--価値と重さアレイ、使用する要素の最大インデックス、重さ制限、ナイーブ再帰。それぞれについて入れるかどうか。
naive_rec::Array Int (Int,Int)-> Int -> Int -> Int
naive_rec item 0 limit = 0
naive_rec item i limit = let no_i_v = naive_rec item (i-1) limit in
                         let usable_i = if ( limit - (snd (item!i)) )>=0
                                          then let use_v = naive_rec item (i-1) (limit - (snd (item!i))) in
                                               use_v+ (fst (item!i))
                                          else no_i_v in
                         max usable_i no_i_v

memo_ls::Array Int (Int,Int) -> Int ->  Int -> [UArray Int Int]
memo_ls item m limit = (listArray (0,limit) (replicate (limit+1) 0)):
                        [ listArray (0,limit)
                            [ let no_i = prev!k in
                              let usable_i = if (k - (snd (item!i))) >=0
                                                then let use_i = (prev!(k-(snd (item!i)))) in
                                                     use_i + (fst (item!i))
                                                else no_i in
                              max no_i usable_i
                            | k <- [0..limit]]
                        | (prev,i) <- zip (memo_ls item m limit) [1..m]]

--vwリスト、リスト要素数、重さ制限、答え。
solver::[(Int,Int)]->Int->Int->Int
solver item_ls m limit = let item = listArray (1,m) item_ls in
                         (last (memo_ls item m limit))!limit

n_tp_get::Int->IO [(Int,Int)]
n_tp_get 0 = return []
n_tp_get n = do
  vw<-getLine
  let v:w:[]= map read (words vw)
  rest<-n_tp_get (n-1)
  return ((v,w):rest)

main::IO()
main=do
  ml<-getLine
  let m:l:[]=map read (words ml)
  dat<-n_tp_get m
  print (solver dat m l)


Measured memory_bytes: 20540
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;
		n=(n*n*n);

		double ans=(double)n/27.0;

		cout<<fixed<<setprecision(12)<<ans<<endl;        
    }
    return 0;
        
}

Measured memory_bytes: 256
import sys

k = int(input())

count = 1
num = 1
l = [str(i+1) for i in range(9)]

if k < 10:
	print(l[k-1])
	sys.exit()

c = 0
while True:
	num = l[c]
	num = int(num[-1])
	if num != 0:
		l.append(l[c]+str(num-1))
	l.append(l[c]+str(num))
	if num != 9:
		l.append(l[c]+str(num+1))

	c += 1
	if len(l) >= k:
		break

print(l[k-1])


Measured memory_bytes: 10136
#include<iostream>
using namespace std;
 
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int n=0;
  int sum=0;
  int total=0;
  for(int i=1;i<=N;i++){
    n=i;
    sum=0;
    sum+=n/10000;
    n=n%10000;
    
    sum+=n/1000;
    n=n%1000;
    
    sum+=n/100;
    n=n%100;
    
    sum+=n/10;
    n=n%10;
    
    sum+=n;
    if(sum>=A && sum<=B)total+=i;
  }
  cout<<total;
  return 0;
}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int h, n;
    cin >> h >> n;
    vector<int> cost(n), mana(n);
    for (int i = 0; i < n; ++i) cin >> cost[i] >> mana[i];
    vector<int> dp(20100, INT_MAX/2);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < h; ++j) {
			int cur = min(j + cost[i], h);
			dp[cur] = min(dp[cur], dp[j] + mana[i]);
		}
	}
	cout << dp[h] << '\n';
}

Measured memory_bytes: 384
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
using namespace std;

int main() {
    int n, i;
    double x[101], y[101], sum = 0, max = 0;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lf", &x[i]);
    }
    for (i = 0; i < n; i++) {
        scanf("%lf", &y[i]);
    }

    for (i = 0; i < n; i++) {
        sum += fabs(x[i] - y[i]);
    }
    printf("%lf\n", sum);
    sum = 0;

    for (i = 0; i < n; i++) {
        sum += pow(fabs(x[i] - y[i]), 2.0);
    }
    printf("%lf\n", sqrt(sum));
    sum = 0;

    for (i = 0; i < n; i++) {
        sum += pow(fabs(x[i] - y[i]), 3.0);
    }
    printf("%lf\n", pow(sum, 1.0 / 3.0));
    sum = 0;

    for (i = 0; i < n; i++) {
        if (fabs(x[i] - y[i]) > max) max = fabs(x[i] - y[i]);
    }
    printf("%lf\n", max);

    return 0;
}

Measured memory_bytes: 3388
import sys

s=[]
ans=[]
 
def dfs(a,b,c,i,root):
    if i==n:
        global ans
        ans=root.copy()
        return True
    l=False
    r=False
    if s[i]=='AB':
        if a>0:
            root.append('B')
            l=dfs(a-1,b+1,c,i+1,root)
            root.pop()
        if not l and b>0:
            root.append('A')
            r=dfs(a+1,b-1,c,i+1,root)
            root.pop()
    elif s[i]=='AC':
        if a>0:
            root.append('C')
            l=dfs(a-1,b,c+1,i+1,root)
            root.pop()
        if not l and c>0:
            root.append('A')
            r=dfs(a+1,b,c-1,i+1,root)
            root.pop()
    else:
        if b>0:
            root.append('C')
            l=dfs(a,b-1,c+1,i+1,root)
            root.pop()
        if not l and c>0:
            root.append('B')
            r=dfs(a,b+1,c-1,i+1,root)
            root.pop()
    return l or r
 
sys.setrecursionlimit(10**6)
n,a,b,c=map(int,input().split())
s=['']*n
for i in range(n):
    s[i]=input()
flag=dfs(a,b,c,0,[])
 
if flag:
    print("Yes")
    for t in ans:
        print(t)
else:
    print("No")

Measured memory_bytes: 176092
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll a, b, q, tmp;
    vector<ll> s, t, x;

    cin >> a >> b >> q;
    rep(i, a){
        cin >> tmp;
        s.push_back(tmp);
    }
    rep(i, b){
        cin >> tmp;
        t.push_back(tmp);
    }
    rep(i, q){
        cin >> tmp;
        x.push_back(tmp);
    }

    vector<ll> scand;
    vector<ll> tcand;
    rep(i, q){
        ll sind = distance(s.begin(), lower_bound(all(s), x[i]));
        ll tind = distance(t.begin(), lower_bound(all(t), x[i]));
        if(sind == s.size()){
            sind = s.size()-1;
            scand.push_back(s[sind]);
        }else if(sind == 0){
            scand.push_back(s[sind]);
        }else{
            scand.push_back(s[sind]);
            scand.push_back(s[sind-1]);
        }

        if(tind == t.size()){
            tind = t.size()-1;
            tcand.push_back(t[tind]);
        }else if(tind == 0){
            tcand.push_back(t[tind]);
        }else{
            tcand.push_back(t[tind]);
            tcand.push_back(t[tind-1]);
        }

        ll res = inf;
        rep(k, scand.size()){
            rep(j, tcand.size()){
                chmin(res, abs(x[i]-scand[k])+abs(scand[k]-tcand[j]));
                chmin(res, abs(x[i]-tcand[j])+abs(tcand[j]-scand[k]));
            }
        }
        cout << res << endl;
        scand.clear();
        tcand.clear();
    }

    return 0;
}


Measured memory_bytes: 3828
// C - Synthetic Kadomatsu
// bit full search
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int N;
vi A(4), L(8);
int ans = INT_MAX;

void calc(vi &v){
	vi sum(4), count(4);
	for(int i=0; i<N; ++i){
		count[v[i]]++;
		sum[v[i]] += L[i];
	}

	if(min({count[1], count[2], count[3]})!=0){
		int s = 0;
		for(int i=1; i<4; ++i){
			s += abs(A[i] - sum[i]);
			if(count[i]>1) s += (count[i]-1) * 10;
		}
		ans = min(ans, s);
	}
}

void bit_full_search(){
	int E = 1<<(N*2);
	for(int i=0; i<E; ++i){
		vi v(N);
		for(int j=0; j<N; ++j) v[j] = (i>>(2*j)) & 3;
		calc(v);
	}
}

int main(){
	cin>>N;
	for(int i=1; i<4; ++i) cin>>A[i];
	for(int i=0; i<N; ++i) cin>>L[i];
	bit_full_search();
	cout<< ans <<endl;
}

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

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

const ll MOD = 998244353;

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

    int N, S; cin >> N >> S;
    vector<int> A(N); cin >> A;
    ll ans = 0;        
    
    vector<int> sum(S+1);
    rep(r, N) {
      sum[0] = r + 1;
      for(int s = sum.size() - 1; s >= 0; s--) {	
	if(s + A[r] <= S) sum[s + A[r]] = (sum[s + A[r]] + sum[s]) % MOD;	
      }
      ans = (ans + sum[S]) % MOD;
    }      
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int N,K;

long long int roop(long long int a,long long int b){
  if(a<=b){
    if(abs(b-a)>=a){
      return a;
    }else return abs(b-a);
  }
  return roop(a%b,b);
}

int main(){
  cin >> N >> K;
  cout << roop(N,K);
}


Measured memory_bytes: 256
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<climits>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    const int MOD = 1e9 + 7;
    for(int i = 0; i < N; ++i) cin >> A[i];
    vector<vector<int>> dp(N + 1, vector<int>(K + 1, 0));
    dp[N][0] = 1;
    for(int i = N - 1; i >= 0; --i) {
        vector<int> pres(K + 2, 0);
        for(int p = 1; p < K + 2; ++p) pres[p] = (1LL * dp[i + 1][p - 1] + pres[p - 1]) % MOD;
        for(int j = 0; j < K + 1; ++j) {
            dp[i][j] = (1LL * pres[j + 1] - pres[max(0, j - A[i])]) % MOD;
            if(dp[i][j] < 0) dp[i][j] += MOD;
            // dp[i][j] += dp[i + 1][j - cand];
            // sum over j - A[i] <= p <= j dp[i + 1][p]
        }
    }
    cout << dp[0][K] << endl;
    return 0;
}



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

int N;
int A[51], B[51];

int main()
{
    cin >> N;
    for (int i=1; i<=N; i++) cin >> A[i], B[i] = A[i];
    sort(B+1,B+1+N);
    int cnt=0;
    for (int i=1; i<=N; i++) cnt += (B[i]!=A[i]);
    if (cnt<=2) cout << "YES";
    else cout << "NO";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
  ll n,d,c=0;
  cin>>n>>d;
  while(n--)
  {
   ll x,y;
    cin>>x>>y;
    if(d*d >= (x*x +y*y)) c++;
  }
  cout<<c;
  return 0;
}

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


int main() {
 int N;
  cin >>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >>A[i];
  double g = 0;
    for(int i=0;i<N;i++) g += 1.00000000/A[i];
 cout <<fixed <<setprecision(6) << 1.00000000/g <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
#define forn(i,n) for (ll i = 0; i < (ll)n; i++)
using ll = long long int;

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s;
	getline(cin, s);

	ll res = 0;
	ll cantB = 0;
	for (char c : s) {
		if (c == 'B') {
			cantB++;
		} else {
			res += cantB;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 720
from sys import stdin

n = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]

# 使わなくて良い
# def get_sieve_of_eratosthenes_new(n):
#     import math
#     if not isinstance(n, int):
#         raise TypeError('n is int type.')
#     if n < 2:
#         raise ValueError('n is more than 2')
#     prime = []
#     limit = math.sqrt(n)
#     data = [i + 1 for i in range(1, n)]
#     while True:
#         p = data[0]
#         if limit <= p:
#             return prime + data
#         prime.append(p)
#         data = [e for e in data if e % p != 0]

# 倍数はOUTという判定を行ってく

# その前に複数あるものはのぞく

cnt = [0] * ((10**6)+1)
for elem in a:
    cnt[elem] += 1

filtered = []

for i in range((10**6)+1):
    if cnt[i] == 1:
        filtered.append(i)

# 倍数かどうかチェック用カウンタ
cnt = [0] * ((10**6)+1)

# 重複のない要素それぞれで倍数を見ていく（上限まで）
a = list(set(a))
for elem in a:
    # 自分自身はカウントしない
    # elemずつ増えるので、倍数という意味になる
    for i in range(elem*2, (10**6)+1, elem):
        cnt[i] += 1

ans = 0
# filteredのうち何らかの倍数になっていないものの数が答え
for i in filtered:
    if cnt[i] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 47404
'use strict'

const main = arg => {
    const input = arg.trim().split("\n");
    const rectangle = [];
    input.some(str => {
        if(str === "0 0"){ return true; } //break;
        const num = str.split(" ");
        const height = parseInt(num[0], 10);
        const width = parseInt(num[1], 10);

        [...Array(height)].forEach((obj, h) => {
            var len = "";
            [...Array(width)].forEach((obj,w) => {
                len += "#";
            });
            rectangle.push(len);
        });
        rectangle.push("");
    });

    console.log(rectangle.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 20660
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
//template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
//template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int k;
    cin >> k;

    int res = 0;

    reps(i,k){
        reps(j,k){
            reps(l,k){
                res += gcd(i,gcd(j,l));
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:64000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;

const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 20007;
const int MAXV = 100007;
const int MAXE = 100000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;


int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("distance.in",  "r", stdin);
    //freopen("distance.out", "w", stdout);
    //freopen("out.txt" , "w" , stdout);

	string s;
	cin >> s;
	int k;
	cin >> k;

	FOR(i,0,SZ(s))
	{
		int nx = ('z' - s[i] + 1) % 26;
		if (k >= nx)
		{
			s[i] = 'a';
			k -= nx;
		}
	}

	s[SZ(s) - 1] = (s[SZ(s) - 1] - 'a' + k) % 26 + 'a';

	cout << s << endl;

    return 0;
}


Measured memory_bytes: 512
n = int(input())
h = list(map(int, input().split()))
h = [h[i] if h[i] != 0 else "#" for i in range(n)]

ans = 0
cond = True
while cond:
    for i in range(n):
        if (i == 0 and h[i] != "#") or (h[i-1] == "#" and h[i] != "#"):
            ans += 1
        
        if h[i] != "#":
            h[i] -= 1

    h = [h[i] if h[i] != 0 else "#" for i in range(n)]

    if h.count("#") == n:
        cond = False

print(ans)


Measured memory_bytes: 3188
N = int(input())
money_JPY = 0
money_BTC = 0
sum = 0
for i in range(0,N,1):
  x, u = input().split()
  if str(u) == "BTC":
    money_BTC += float(x)
  else:
    money_JPY += int(x)
money_BTC = money_BTC*380000.0
sum = money_BTC+money_JPY
print(sum)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
#define ll long long
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; } 
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }

const ll N=200010;
ll a[N],q[N],n,tot;
int main(){
	n=read();
	For(i,1,n)	a[i]=read();
	sort(a+1,a+n+1);
	For(i,1,n)	if (a[i]==a[i+1])	q[++tot]=a[i],i++;
	writeln(q[tot]*q[tot-1]);
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        if (n == 1)
        {
            Console.WriteLine("Hello World");
            Console.ReadLine();
            return;
        }

        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());


        Console.WriteLine(a + b);
        Console.ReadLine();
    }
}

Measured memory_bytes: 11092
import sys
inputs = []
for line in sys.stdin:
    inputs.append(line)

n = len(inputs)
for _ in range(n // 2):
    a = list(map(int, inputs[_ * 2].split()))
    b = list(map(int, inputs[_ * 2 + 1].split()))
    hit = 0
    blow = 0
    for i in range(4):
        if b[i] == a[i]:
            hit += 1
        elif b[i] in a:
            blow += 1
    print(hit, blow)

Measured memory_bytes: 7532
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	cnt := 0
	s := nextInt()
	t := nextInt()
	cnt = (t-s)/(s-1) + 1
	if (t-s)%(s-1) >= 1 {
		cnt++
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640