akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let s: String = readln();
    let k: usize = readln();
    let mut st = HashSet::new();
    let n = s.len();
    for i in 0..n {
        for j in i + 1..i + 6 {
            if j <= n {
                st.insert(&s[i..j]);
            }
        }
    }
    let mut v = Vec::new();
    for x in st {
        v.push(x);
    }
    v.sort();
    println!("{}", v[k - 1]);
}

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

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define F first
#define S second
#define MOD 1000000007

auto lcmFactors = map<Int, Int>();

void factorize(Int n) {
    Int factor = 0;
    Int factorCount = 0;
    Int q = n;
    if (n >= 2) {
        for (Int i = 2; i * i <= n;) {
            if (q % i == 0) {
                if (i != factor) {
                    factor = i;
                    factorCount = 1;
                } else {
                    factorCount++;
                }
                q /= i;
            } else {
                if (factor > 0) {
                    lcmFactors[factor] = max(lcmFactors[factor], factorCount);
                    factor = 0;
                }
                i++;
            }
        }
    }
    if (q > 1) {
        lcmFactors[q] = max(lcmFactors[q], 1LL);
    }
}

Int modinv(Int a, Int m) {
    Int b = m, u = 1, v = 0;
    while (b) {
        Int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    Int n;
    cin >> n;
    auto v = vector<Int>();
    rep(i, n) {
        Int a;
        cin >> a;
        v.PB(a);
        factorize(a);
    }
    Int LCM = 1;
    for (auto &factor : lcmFactors) {
        auto p = factor.F;
        auto e = factor.S;
        rep(i, e) {
            LCM *= p;
            LCM %= MOD;
        }
    }
    Int ans = 0;
    for (auto a : v) {
        auto result = LCM * modinv(a, MOD) % MOD;
        ans += result;
        ans %= MOD;
    }
    PUTS(ans);
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int A, B;
    cin>>A>>B;
    cout <<max(A-B*2, 0)<<endl;
    return 0;
}


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

const int maxl=3e5+10;

int n,m,cas,k,cnt,tot,ans;
int a[maxl],b[maxl];
char s[maxl];
bool in[maxl]; 

inline void prework()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
} 

inline void mainwork()
{
	for(int i=k+1;i<=n;i++)
	if(a[i]>a[i-k])
		puts("Yes");
	else
		puts("No");
}

inline void print()
{
	
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	for(cas=1;cas<=t;cas++)
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}

Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  double now = 100;
  ll ans = 0;
  rep(i, 1e5) {
    now *= 1.01;
    now = ll(now);
    ans++;
    if(now >= x) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
n,k=map(int,input().split())
b=[0]*(n+1)
for i in range(n):
    b[i+1]=b[i]+int(input())-k
a=sorted(set(b))
s={a[i-1]:i for i in range(1,len(a)+1)}
c=[]
for i in b:
    c.append(s[i])
b=[0]*(len(a)+1)
def f(x):
    c=0
    while x>0:
        c+=b[x]
        x-=x&-x
    return c
def g(x):
    while x<len(a)+1:
        b[x]+=1
        x+=x&-x
e=0
for i in range(n+1):
    e+=f(c[i])
    g(c[i])
print(e)

Measured memory_bytes: 89008
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

typedef long long ll;

using namespace std;

char buf[512];
pair<int, int> width_pos[512][512];
int size[512];

int main()
{
	while (true)
	{
		int H, W;
		cin.getline(buf, sizeof(buf));
		sscanf(buf, "%d %d", &H, &W);
		if (H == 0 && W == 0)
			break;


		for (int i = 0; i <= W; ++i)
		{
			width_pos[i][0] = make_pair(0, 0);
			for (int j = 1; j <= H; ++j)
				width_pos[i][j] = make_pair(9999, 0);
			size[i] = 1;
		}

		int ans = 0;
		for (int i = 1; i <= H; ++i)
		{
			cin.getline(buf, sizeof(buf));
			int w = 0;
			for (int j = 1; j <= W; ++j)
			{
				if (buf[j-1] == '.')
				{
					++w;
				}
				else
				{
					w = 0;
				}

				for (int k = w; k > 0; --k)
					ans = max(ans, k * (i - lower_bound(width_pos[j], width_pos[j] + size[j], make_pair(k, 0))[-1].second));

				pair<int, int>* t = lower_bound(width_pos[j], width_pos[j] + size[j], make_pair(w, 0));
				*t = make_pair(w, i);
				size[j] = t - width_pos[j] + 1;
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

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

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

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> a;
  vector<vector<LL>> memo;
  Solver(LL n) : n(n), a(n), memo(n + 1, vector<LL>(n + 1, LINF)){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    cout << calc(0, 0, n) << endl;
  }
  LL calc(int turn, int lb, int ub) {
    if (memo[lb][ub] < LINF) return memo[lb][ub];
    if (lb == ub) return 0;
    LL ret;
    if (turn % 2 == 0) {
      //taro
      ret = max(calc(turn + 1, lb + 1, ub) + a[lb], calc(turn + 1, lb, ub - 1) + a[ub - 1]);
    } else {
      //jiro
      ret = min(calc(turn + 1, lb + 1, ub) - a[lb], calc(turn + 1, lb, ub - 1) - a[ub - 1]);
    }
    return memo[lb][ub] = ret;
  }
};

}  // namespace Problem

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

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


Measured memory_bytes: 71040
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int s[10000];
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    int q;
    cin >> q;
    int count=0;
    for(int i=0;i<q;i++){
        int x;
        cin >> x;
        for(int j=0;j<n;j++){
            if (x == s[j]){
                count++;
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;


public class Main {

  public static void main(String [] args) {

    Scanner s = new Scanner(System.in);
    int a = s.nextInt();
    int b = s.nextInt();

    int n = b - a - 1;

    System.out.println((n * (n + 1) / 2) - a);

  }

}

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

int main() {
    string s;
    cin >> s;
    rep (i, s.size()) s[i] -= 3, s[i] += (s[i] < 'A' ? 'Z' - 'A' + 1 : 0);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long a, b, c;

	cin >> a >> b >> c;
	long long ans;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)  {
		ans = 0;
	} else {
		ans = min({a*b, b*c, c*a});
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
char a[105],b[105];
int n,i;
int main()
{
    cin>>n;
    cin>>a>>b;
    for(i=0;i<2*n;i++)
    {
        if(i%2==0)
        {
            cout<<a[i/2];
        }
        else
        {
            cout<<b[i/2];
        }
    }
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	int N;
	cin >> N;
	vector<int> A(N); //教室にいた生徒数
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> indx(N);
	for (int i = 0; i < N; i++) {
		indx[A[i] - 1] = i + 1;
	}
	for (int i = 0; i < N; i++) {
		cout << indx[i] << endl;
	}
}

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

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

	for( int i = 0; i < n; i++ )
	{
		int a; 
		cin >> a;
		while( 0 < a ) {
			if( (a % 2) != 0 ) {
				break;
			}
			tt++;
			a /= 2;
		}
	}
	cout << tt << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    writeln!(o, "{}", solve(n)).unwrap();
}
fn solve(n: usize) -> usize {
    let mut ans = 0;
    divisors(n, |x| {
        let m_1 = n / x;
        let m = m_1 - 1;
        if x < m {
            ans += m;
        }
    });
    ans
}
fn divisors<F: FnMut(usize)>(n: usize, mut f: F) {
    fn divisors_by<F: FnMut(usize)>(fs: &[(usize, usize)], mut n: usize, f: &mut F) {
        if fs.is_empty() {
            f(n);
            return;
        }
        let (p, c) = fs[0];
        for _ in 0..c + 1 {
            divisors_by(&fs[1..], n, f);
            n *= p;
        }
    }
    divisors_by(&factorize(n), 1, &mut f)
}
fn factorize(mut n: usize) -> Vec<(usize, usize)> {
    assert!(n != 0);

    fn try_push_factor(n: &mut usize, f: usize, fs: &mut Vec<(usize, usize)>) -> bool {
        let mut c = 0;
        while *n % f == 0 {
            *n /= f;
            c += 1;
        }
        if c != 0 {
            fs.push((f, c));
            true
        } else {
            false
        }
    }
    let mut fs = Vec::new();

    for &f in &[2, 3, 5] {
        try_push_factor(&mut n, f, &mut fs);
    }
    let mut f = 7;
    let mut end = (n as f64).sqrt() as usize + 1;
    while f < end {
        if try_push_factor(&mut n, f, &mut fs) | try_push_factor(&mut n, f + 4, &mut fs) {
            end = (n as f64).sqrt() as usize + 1;
        }
        f += 6;
    }
    if n != 1 {
        fs.push((n, 1));
    }
    fs
}


mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  char c;
  cin >> h >> w;
  vector<vector<int>> vc(w+1,vector<int>(h+1,0));
  vector<vector<int>> dp(w+1,vector<int>(h+1,inf));
  rep(j,h){
    rep(i,w){
      cin >> c;
      vc[i][j] = c - '0';
    }
  }
  dp[0][0] = vc[0][0];
  REP(i,0,w){
    REP(j,0,h){
      dp[i+1][j] = min(dp[i][j]+vc[i+1][j],dp[i+1][j]);
      dp[i][j+1] = min(dp[i][j]+vc[i][j+1],dp[i][j+1]);
    }
  }
  cout << dp[w-1][h-1]<<endl;
  return 0;
}

Measured memory_bytes: 3228
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        ll n, k;
        cin >> n >> k;
        auto x = n % k;
        db(x);
        cout << min(x, abs(k - x)) << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define nmax_def 110000
#define Cmax_def 2200
#define mod 998244353
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;


vl pow_;
void pow_ini(ll n) {
	pow_.push_back(n);
	rep(j, 62) {
		ll nxt = pow_[j] * pow_[j];
		nxt %= mod;
		pow_.push_back(nxt);
	}
	return;
}

ll pow1(ll k) {
	ll ans = 1;
	rep(ntmp, 62) {
		if ((k >> ntmp) % 2 == 1) {
			ans *= pow_[ntmp];
			ans %= mod;
		}
	}
	return ans;
}

vl fact;
vl fact_inv;

void fact_ini(ll n) {
	fact.resize(n + 1);
	fact[0] = 1;
	for (ll i = 1; i <= n; i++) {
		ll fact_tmp = fact[i - 1] * i;
		fact_tmp %= mod;
		fact[i] = fact_tmp;
	}
	fact_inv.resize(n + 1);
	pow_ini(fact[n]);
	fact_inv[n] = pow1(mod - 2);
	for (ll i = n - 1; i >= 0; i--) {
		fact_inv[i] = fact_inv[i + 1] * (i + 1);
		fact_inv[i] %= mod;
	}
}

ll nCm(ll n, ll m) {
	assert(m >= 0);
	assert(n < fact.size());
	assert(n >= m);
	ll ans = fact[n] * fact_inv[m];
	ans %= mod;
	ans *= fact_inv[n - m];
	ans %= mod;
	return ans;
}

int main() {
	fact_ini(22000000);
	ll N, M, K;
	cin >> N >> M >> K;
	ll ans = 0;
	ll M_1 = 1;
	rep(i, N - 1 - K) {
		M_1 *= (M - 1);
		M_1 %= mod;
	}
	rrep(k, K + 1) {
		ans += nCm(N - 1, k) * M_1;
		ans %= mod;
		M_1 *= (M - 1);
		M_1 %= mod;
	}
	ans *= M;
	ans %= mod;
	cout << ans << endl;
	return 0;
}

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

int main(){
  int count=0,digit,a,b;

  while(scanf("%d%d",&a,&b)!=EOF){
    digit = a+b;
    while(digit!=0){
      digit/=10;
      count++;
}
    cout << count << endl; 
    count =0; 
}
  return 0;
}
 

Measured memory_bytes: 1208
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var pos int

type Order struct {
	pre, in, post []int
}

func (o *Order) rec(l, r int) {
	if l >= r {
		return
	}
	root := o.pre[pos]
	pos++

	var m int
	for i, elem := range o.in {
		if elem == root {
			m = i
			break
		}
	}

	o.rec(l, m)
	o.rec(m+1, r)
	o.post = append(o.post, root)
}

func (o *Order) solve() string {
	var out bytes.Buffer

	o.rec(0, len(o.pre))
	for i := 0; i < len(o.pre); i++ {
		out.WriteString(fmt.Sprintf("%d ", o.post[i]))
	}

	return strings.TrimRight(out.String(), " ")
}

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var order Order
	for i := 0; i < n; i++ {
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		order.pre = append(order.pre, k)
	}

	for i := 0; i < n; i++ {
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		order.in = append(order.in, k)
	}

	return order.solve()
}

func main() {
	fmt.Println(answer(os.Stdin))
}



Measured memory_bytes: 1156
#include <iostream>
using namespace std;
int main(void)
{
	int n,a,b,i,sum=0;
	cin >> n >> a >> b;
	for( i=1;i<=n;i++ )
	{
		int wa=i/10000 + (i%10000)/1000 + ((i%10000)%1000)/100 + (((i%10000)%1000)%100)/10 + (((i%10000)%1000)%100)%10;
		if( a<=wa && wa<=b ) sum+=i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// ecnerwal氏.
// https://atcoder.jp/contests/abc127/submissions/5623318
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    int Q;
    scanf("%d", &Q);
    priority_queue<LL, vector<LL>, less<LL>> lows;
    priority_queue<LL, vector<LL>, greater<LL>> highs;
    LL curValue = 0;
    for(int q = 0; q < Q; q++){
        int t;
        scanf("%d", &t);
        if(t == 1){
            LL a, b;
            scanf("%lld %lld", &a, &b);
            curValue += b;
            assert(lows.size() == highs.size() || lows.size() == highs.size() + 1);
            if(lows.empty()){
                lows.push(a);
            }else{
                curValue += abs(lows.top() - a);
                if(a >= lows.top()){
                    highs.push(a);
                    if(highs.size() == lows.size() + 1){
                        curValue -= highs.top() - lows.top();
                        lows.push(highs.top());
                        highs.pop();
                    }
                }else{
                    lows.push(a);
                    if(lows.size() == highs.size() + 2){
                        highs.push(lows.top());
                        lows.pop();
                    }
                }
            }
        }else if(t == 2){
            printf("%lld %lld\n", lows.top(), curValue);
        }else{
            assert(false);
        }
    }
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define ll long long int

char a,b,c,d,e,f;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>a>>b>>c>>d>>e>>f;
    if(d==c && e==f ){
        cout<<"Yes";
    }
    else cout<<"No";


    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7
h,w,k = map(int, input().split())

patterns = [1,1,2,3,5,8,13,21]

dp = [ [0]*w for _ in range(h+1) ]
dp[0][0] = 1
for i in range(1,h+1):
    for wi in range(w):
        dp[i][wi] = dp[i-1][wi] * patterns[w-1-wi] * patterns[wi-0]
        if wi > 0:
            dp[i][wi] += dp[i-1][wi-1] * patterns[w-1-wi] * patterns[wi-1]
        if wi < w-1:
            dp[i][wi] += dp[i-1][wi+1] * patterns[w-1-wi-1] * patterns[wi-0]
        dp[i][wi] %= MOD

print(dp[h][k-1]%MOD)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;

long long nC2(long long n)
{
    return n * (n - 1) / 2;
}

int main()
{
    long long n, test;
    cin >> n;
    VI a(n, 0);
    VI all(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> test;
        a[i] = test;
        all[test]++;
    }
    long long sum = 0;
    for (int i = 0; i < n + 1; i++)
    {
        sum += nC2(all[i]);
    }
    for (int i = 0; i < n; i++)
    {
        cout << sum - nC2(all[a[i]]) + nC2(all[a[i]] - 1) << endl;
    }
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int N,M;
  cin>>N>>M;
  int ALL = N*M;
  int ANS;
  if(N==1 || M == 1)
  {

    ANS = max(0LL,ALL -2);
    if(N*M == 1)ANS = 1;
  }
  else if(N ==2 || M == 2)
  {
    ANS = 0;
  }
  else
  {
    ANS = ALL - 2*M -2*N + 4;
  }
  
  cout<<ANS<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int p, q, r; cin >> p >> q >> r;
    int ans = p + q;
    ans = min(ans, q + r);
    ans = min(ans, r + p);
    cout << ans << endl;
}


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

typedef complex<double> Point;

double distance(Point p, Point q) {
  return abs(p - q);
}

class Line {
  Point p1_, p2_;
  friend ostream& operator<<(ostream& out, const Line& l);
  public :
    Line(Point p1, Point p2) : p1_(p1), p2_(p2) {}
    Point p1() const {
      return p1_;
    }
    Point p2() const {
      return p2_;
    }
};
ostream& operator<<(ostream& out, const Line &l) {
  return out<<l.p1()<<", "<<l.p2();
}
Line get_vertical_bisector(const Point &p1, const Point &p2) {
  Point mid = (p1 + p2) / 2.0;
  Point normal_vector = (p2 - p1) * Point(0, 1);
  return Line(mid, normal_vector + mid);
}
double cross(Point a, Point b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
Point get_intersection(Line l1, Line l2) {
  Point a = l1.p2() - l1.p1();
  Point b = l2.p2() - l2.p1();
  return l1.p1() + a * cross(b, l2.p1() - l1.p1()) / cross(b, a);
}
int main() {
  int n;
  cin>>n;
  Point p[n];
  for (int i=0; i<n; i++) {
    int x, y;
    cin>>x>>y;
    p[i] = Point(x, y);
  }
  double ans = 2000;
  double eps = 1e-10;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      Point mid = (p[i] + p[j]) / 2.0;
      double r = distance(mid, p[i]);
      bool ok = true;
      for (int k=0; k<n;k++) {
        if (distance(mid, p[k]) > r + eps) {
          ok = false;
          break;
        }
      }
      if (ok) {
        ans = min(r, ans);
      }
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      for (int k=j+1; k<n; k++) {
        if (cross(p[i] - p[k], p[j] - p[k]) < eps
            && cross(p[i] - p[k], p[j] - p[k]) > -eps) {
          continue;
        }
        Line l1 = get_vertical_bisector(p[i], p[j]);
        Line l2 = get_vertical_bisector(p[j], p[k]);
        Point c = get_intersection(l1, l2);
        double r = distance(c, p[i]);
        bool ok = true;
        for (int l=0; l<n; l++) {
          if (distance(c, p[l]) > r + eps) {
            ok = false;
            break;
          }
        }
        if (ok) {
          ans = min(r, ans);
        }
      }
    }
  }
  printf("%.9lf\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<unistd.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
vector<ll> x,invx;

ll modpow(ll x,ll p){
	if(p==0) return 1;
	if(p%2){return x*modpow(x,p-1)%MOD;}
	else {
		ll n=modpow(x,p/2);
		return n*n%MOD;
	}
}

inline ll factorial(int n){
	x.push_back(1);
	ll tmp=1;
	for(int i=1;i<=n;i++){
		tmp*=i;
		tmp%=MOD;
		x.push_back(tmp);
	}
}

inline ll comb(int n,int r){
	if(r>n) return 0;
	ll ret=x[n]*invx[r]%MOD*invx[n-r]%MOD;
	return ret;
}

int main(){
	int h,w,a,b;
	cin >> h >> w >> a >> b;
	factorial(h+w);
	for(int i=0;i<=h+w;i++){
		invx.push_back(modpow(x[i],MOD-2));
	}
	ll ans=0;
	for(int i=b;i<w;i++){
		ans+=comb(h-1-a+i,i)%MOD*comb(a-1+w-1-i,a-1)%MOD;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4848
X, Y = map(int,input().split())

ans = 0

if X == 3:
  ans = ans + 100000
elif X == 2:
  ans = ans + 200000
elif X == 1:
  ans = ans + 300000

if Y == 3:
  ans = ans + 100000
elif Y== 2:
  ans = ans + 200000
elif Y == 1:
  ans = ans + 300000

if (X == 1)and(Y==1):
  ans = ans+ 400000
print(ans)

Measured memory_bytes: 3064
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

bool sortBySec(pair<int, ll> &a, pair<int, ll> &b) {
  return (a.second > b.second);
}

int main(void) {
  int N,M;cin>>N>>M;
  ll A[N];
  REP(i,N) {
    cin>>A[i];
  }

  vector<pair<int, ll>> Buf;

  REP(i,M) {
    int B,C;cin>>B>>C;
    Buf.push_back(make_pair(B, C));
  }

  sort(A, A+N);

  sort(Buf.begin(), Buf.end(), sortBySec);

  // p("=========");

  vector<ll> D;

  REP(i,M) {
    REP(j,Buf[i].first) {
      if(D.size() <= N) D.push_back(Buf[i].second);
      else break;
    }
    if(D.size() >= N) {
      break;
    }
  }

  sort(D.begin(), D.end(), greater<ll>());

  // REP(i,D.size()) {
  //   p(D[i]);
  // }

  ll sum = 0;
  REP(i,N) {
    // p(D[i], A[i]);
    if(i < D.size() && D[i]>A[i]) {
      sum += D[i];
    } else {
      sum += A[i];
    }
  }
  p(sum);
  return 0;
}



Measured memory_bytes: 4464
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  long n, m;
  rd(n, m);
  import std.math : sqrt;

  for (long k = m; k >= 1; k--) {
    if (m >= k * n && (m - k * n) % k == 0) {
      writeln(k);
      return;
    }
  }

  import std.exception : enforce;

  enforce(false);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int MAX = 200000;

vector<int> e[MAX], re[MAX];
bool cycle[MAX], used[MAX];
int ans[MAX], degout[MAX];

int dfs(int u) {
    int ret = u;
    used[u] = true;
    for (auto v: re[u]) {
        if (used[v]) {
            if (cycle[v]) return v;
            cycle[v] = true;
        }
        ret = dfs(v);
    }
    return ret;
}

int main(void) {
    int i, n;
    scanf("%d",&n);
    set<int> leaves;
    REP (i,n) leaves.insert(i);
    REP (i,n) {
        int p;
        scanf("%d",&p);
        p--;
        e[p].push_back(i);
        re[i].push_back(p);
        leaves.erase(p);
        degout[p]++;
    }
    int start = dfs(0);
    queue<int> q;
    for (auto x: leaves) q.push(x);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        set<int> st;
        for (auto v: e[u]) {
            st.insert(ans[v]);
        }
        REP (i,0,e[u].size()) if (!st.count(i)) {
            ans[u] = i;
            break;
        }
        for (auto v: re[u]) if (!cycle[v]) {
            if (--degout[v] == 0) q.push(v);
        }
    }
    set<int> st;
    for (auto v: e[start]) if (!cycle[v]) {
        st.insert(ans[v]);
    }
    vector<int> cand;
    REP (i,0,e[start].size()+1) if (cand.size() < 2 && !st.count(i)) {
        cand.push_back(i);
    }
    for (auto x: cand) {
        ans[start] = x;
        queue<int> q;
        q.push(start);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (auto v: re[u]) {
                set<int> st;
                for (auto w: e[v]) st.insert(ans[w]);
                int tmp;
                REP (i,0,e[v].size()) if (!st.count(i)) {
                    tmp = i;
                    break;
                }
                if (v == start) {
                    if (ans[v] == tmp) {
                        puts("POSSIBLE");
                        return 0;
                    }
                    break;
                }
                ans[v] = tmp;
                q.push(v);
            }
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 37376
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <functional>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(var,init,end) for(int var=init;var<end;var++)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	int cnt = 0;
	FOR(i, 0, N) {
		while (a[i] % 2 == 0) {
			a[i] = a[i]/2;
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<map>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
vi final(9);
int dx[]={-4,-1,1,4};

bool move(vi &c,int d){
	int z=c[8];
	if(z+dx[d]<0||z+dx[d]>7)return 0;
	if(z==3&&d==2||z==4&&d==1)return 0;
	swap(c[z],c[z+dx[d]]);
	c[8]+=dx[d];
	return 1;
}
int main(){
	rep(i,9)final[i]=i%8;
	map<vi,int> visited; visited[final]=0;
	vector<vi> frontier,next; frontier.push_back(final);
	int step=0;
	
	vi goal(9);
	while(cin>>goal[0]){
		rep(i,7){
			cin>>goal[i+1];
			if(!goal[i+1])goal[8]=i+1;
		}
		while(visited.find(goal)==visited.end()){
			rep(i,frontier.size()){
				rep(d,4){
					vi c=frontier[i];
					if(!move(c,d))continue;
					if(visited.find(c)==visited.end())next.push_back(c),visited[c]=step+1;
				}
			}
			frontier=next; next.clear();
			step++;
		}
		cout<<visited[goal]<<endl;
	}
}

Measured memory_bytes: 0
/**************
*	Shell Sort
*************/

#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>	//??£?¨?
using namespace std;

void insertionSort(vector<int>* A, int g, int* cnt  ){

	for(unsigned int i=g ; i<(A->size()); i++){
		int v = (*A)[i];
		int j = i-g;
		while(j>=0 && (*A)[j]>v){
			(*A)[j+g] = (*A)[j];
			j = j-g;
			(*cnt)++;
		}
		(*A)[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(vector<int>* A, vector<int>* G, int* cnt){
//	*cnt =0;
//	int m = A->size();
//	vector<int> G(1,m);
	for(unsigned int i=0; i<(G->size()); i++){
		insertionSort(A, (*G)[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	//??\???
	int n;
	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
		cin >> A[i];
	}

	//??????
// 	vector<int> G(1,1);
	vector<int> G;
// 	for(int i= n; i!=0; --i){
// 	    G.push_back(i) ;
// 	}
vector<int> Temp;
int sum=0;
for(int i=0; i <n ; ++i){
    sum += pow(3,i);
    Temp.push_back(sum);
}
//   for(int i=0; i<Temp.size();i++){cout <<Temp[i] << endl;}

for(int j=0; Temp[j]<=n; j++){
    G.push_back(Temp[j]);
}
//  for(int i=0; i<G.size();i++){cout <<G[i] << endl;}

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

	int cnt = 0;
	shellSort(&A, &G, &cnt);

	//??????
	cout << G.size() << endl;
	for(unsigned int i=0; i<(G.size()); i++){
		cout << G[i];
		if(i!=(G.size()-1)){
			 cout <<" " ;
		}
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0; i< n; i++){
		cout << A[i]<< endl;
	}

	return 0;
}
//-----------------------------------------------

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

int main(int argc, const char * argv[]) {
    int A, B;
    string s, t;
    cin >> A >> B;
    
    int cnt = 0;
    for (int i = A; i <= B; i++) {
        
        s = to_string(i);
        t = s;
        reverse(t.begin(), t.end());
        if (s == t) {
            cnt++;
        }
        
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    sort(ALL(A));
    int ans = 0;
    do {
        if (M < A[ans]) break;
        M -= A[ans];
        ans++;
    } while(ans < N-1);
    if (M == A[N-1]) ans++;

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
require 'pp'

n, h = ARGF.gets.split(" ").map(&:to_i)

ai = []
bi = []
for _ in 0...n
  a, b = ARGF.gets.split(" ").map(&:to_i)
  ai << a
  bi << b
end

amax = ai.max

bi = bi.sort.reverse
count = 0
for i in 0...bi.size
  break if bi[i] <= amax

  h -= bi[i]
  count += 1

  if h <= 0
    puts count
    exit
  end
end

count += h/amax
count+=1 if h % amax != 0 

puts count


Measured memory_bytes: 7684
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    //N = 1000000000000001;
    ll num_mozi;

    ltmp = N;
    ll base = 26;
    while(ltmp>base){
        ltmp -= base;
        base*=26;
        num_mozi++;
    }

    base = base/26;
    //cout << num_mozi << endl;
    //cout << ltmp << endl;
    //cout << base << endl;
    ltmp = N ;
    string S = "";
    ll val = ltmp % 26;
    ltmp -= val;
    if(val==0){
        val = 26;
        //val = ltmp / 26;
        ltmp-=26;
    }
    S = char('a'+val-1) + S;

    while(ltmp>0){
        ltmp = ltmp / 26;
        val = ltmp % 26;
        ltmp -= val;
        if(val==0){
            val = 26;
            ltmp-=26;
        }
        S = char('a'+val-1) + S;
    }

    cout << S;



    

}

Measured memory_bytes: 3660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;

  string s1, s2;
  cin >> n >> s1 >> s2;

  llong ans;
  if(s1[0] == s2[0]){
    ans = 3;
    bool len = true;

    FOR(i,1,n){
      if(s1[i] == s2[i]){
        if(len){
          len = true;
          ans = (ans * 2) % SUR;
        }else{
          len =true;
          continue;
        }
      }else{
        if(len){
          i++;
          ans = (ans * 2) % SUR;
          len = false;
          continue;
        }else{
          i++;
          ans = (ans * 3) % SUR;
          len = false;
        }
      }
    }
  }else{
    bool len = false;
    ans = 6;
    FOR(i,2,n){
      if(s1[i] == s2[i]){
        if(len){
          len = true;
          ans = (ans * 2) % SUR;
        }else{
          len =true;
          continue;
        }
      }else{
        if(len){
          i++;
          ans = (ans * 2) % SUR;
          len =false;
          continue;
        }else{
          i++;
          ans = (ans * 3) % SUR;
        }
      }
    }
  }

  cout << ans << "\n";
  return 0;
}



Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'

const int INF = 1e9;

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

  int n; cin >> n;
  int h[n]; rep(i, n) cin >> h[i];

  int dp[101010];  // dp[i] : i + 1 番目の足場にたどりつくための最小コスト
  fill(dp, dp + 101010, INF);

  dp[0] = 0; dp[1] = abs(h[0] - h[1]);

  for (int i = 1; i < n; ++i){
    dp[i + 1] = min(dp[i - 1] + abs(h[i + 1] - h[i - 1]), dp[i] + abs(h[i + 1] - h[i]));
  }
  print(dp[n - 1]);

  return 0;
}

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;

bool	comp(int a, int b)
{
	return a > b;
}

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int	N;
	std::cin >> N;
	vi	a(N);
	for (auto &v : a) std::cin >> v;
	std::sort(all(a), comp);

	int		score[2] = {0,0};

	FOR(i,0,N)
		score[i%2] += a[i];
	pnl(score[0]-score[1]);
}



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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

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

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N; cin >> N;
	if (N == 1) {
		puts("1");
		puts("0");
	} else if (N == 2) {
		puts("2");
		puts("0");
		puts("11");
	} else {
		cout << N - 1 << endl;
		for (int i = 2; i <= N; ++i) {
			string s;
			s.pb('0');
			rep(j, i-2) {
				s.pb('1');
			}
			s.pb('0');
			cout << s << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3220
import java.io.*;
import java.util.*;
public class Main {
     public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer s = new StringTokenizer(br.readLine()," ");
	int input1 = Integer.parseInt(s.nextToken());
	int input2 = Integer.parseInt(s.nextToken());
	int input3 = Integer.parseInt(s.nextToken());

	if(input1 < input2 && input2 < input3){
	System.out.println("Yes");
	}else{
	System.out.println("No");
        }
    }
}

Measured memory_bytes: 24252
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5
7 46 11 20 11
)");
#define cin input
#endif

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

	int r = 0;
	REP (i, n)
	{
		int a;
		cin >> a;
		r += a - 1;
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 888