akhauriyash/Code-Regression huggingface dataset:
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int result[N],f[N],b[N];
int mul(int a,int b){
  return ((a)*(b))%M;
}
ll powM(ll b, int p) {
  ll r=1;
  for(; p; b=b*b%M, p/=2)
    if(p&1)
      r=r*b%M;
  return r;
}
// long long C(long long n,long long r)
// {
//     long long N=1,R=1;
//     if(r>n or r<0)return 0;
//     if(n==r or r==0)return 1;
//     for(long long i=1;i<=n;i++) N=N*i%M;
//     for(long long i=1;i<=r;i++) R=R*i%M;
//     for(long long i=1;i<=n-r;i++) R=R*i%M;
//     return (N*powM(R,M-2))%M;
// }
int invM(int x){
  return powM(x,M-2);
}
void binomialCoeff(int n) 
{ 
  f[0]=b[0]=1;
  rep(i,1,n){
    f[i]=mul(f[i-1],i);
    b[i]=invM(f[i]);
  }
  // rep(i,1,n){
  //   C[i]=mul(mul(f[n],b[n-i]),b[i]);
  // }
} 
int C(int n,int i){
  return mul(mul(f[n],b[n-i]),b[i]);
}
void fact_dp(int n)

{

    if (n >= 0) 

    {

        result[0] = 1;

        for (int i = 1; i <= n; ++i) 

        {

            result[i] = mul(i , result[i - 1]);

        }

    }

}
int add(int a,int b){
  a+=b;
  if(a>=M)a-=M;
  return a;
}
ll sub(ll a,ll b){
  return ((a%M)-(b%M)+M)%M;
}
void solve(){
  int n,m;cin>>n>>m;
  fact_dp(N-1);
  binomialCoeff(m);
  int x=mul(C(m,n),result[n]);
  int ans=mul(x,x);
  // cout<<sub(ans,mul(sub(powM(2,n),1),mul(1,C(m,n))));
  // cout<<sub(ans,mul(n,mul(m,mul(result[n-1],C(m-1,n-1)))));
  int cnt=0;
  rep(i,1,n){
    int c=1;
    c=mul(c,mul(C(m,n),mul(C(n,i),result[n])));
    c=mul(c,mul(C(m-i,n-i),result[n-i]));
    if(i&1)cnt=add(cnt,c);
    else cnt=sub(cnt,c);
  }
  cout<<sub(ans,cnt);
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 10;

int N, Fix[MAX_N], Ans[MAX_N];
vector<int> Ed[MAX_N];
struct RG{
	int x, y, p;
	RG(int xx, int yy, int pp=1) : x(xx), y(yy), p(pp) {}
	RG() {RG(0, 0, 1);}
	void update(const RG &o) {
		RG a = RG(x, y, p);
		RG b = RG(o.x-1, o.y+1, o.p);
		if(a.p == 2 and b.p == 2 and abs(a.x%2) != abs(b.x%2)) x = 0, y = -1, p = 1;
		else{
			if(a.p == b.p) x = max(a.x, b.x), y = min(a.y, b.y);
			else{
				if(a.p == 2) swap(a, b);
				if(abs(a.x%2) != abs(b.x%2)) a.x++;
				if(abs(a.y%2) != abs(b.y%2)) a.y--;
				x = max(a.x, b.x), y = min(a.y, b.y), p = 2;
			}
		}
		//printf("[%d %d %d] (%d %d %d)\n", x, y, p, b.x, b.y, b.p);
	}
};
RG Range[MAX_N]; // [min, max];
bool getCan(int v, int p) {
	for(int w : Ed[v]) if(w != p) if(!getCan(w, v)) return false;
	if(Fix[v] == -1) {
		Range[v] = RG(-INF, +INF, 1);
		for(int w : Ed[v]) if(w != p) Range[v].update(Range[w]);
	}else Range[v] = RG(Fix[v], Fix[v], 2);
	if(Fix[p] != -1) Range[v].update(RG(Fix[p], Fix[p], 2));
	if(Range[v].x > Range[v].y) return false;
	//printf("%d : [%d %d, %d]\n", v, Range[v].x, Range[v].y, Range[v].p);
	return true;
}
void getAns(int v, int p) {
	Ans[v] = Range[v].x;
	for(int w : Ed[v]) if(w != p) Range[w].update(RG(Ans[v], Ans[v], 2)), getAns(w, v);
}
int main() {
	cin >> N; for(int i=1; i<N; i++) {int x, y; scanf("%d%d", &x, &y);Ed[x].push_back(y); Ed[y].push_back(x);}
	for(int i=0; i<=N; i++) Fix[i] = -1;
	int K; cin >> K; for(int i=0; i<K; i++) {int v, p; scanf("%d%d", &v, &p);Fix[v] = p;}

	bool isCan = getCan(1, 0);
	puts(isCan ? "Yes" : "No");
	if(isCan) {
		getAns(1, 0);
		for(int i=1; i<=N; i++) printf("%d\n", Ans[i]);
	}
	return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



#if 0
const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

const int MAXN = (int) 2e5 + 5;

char s[MAXN], t[MAXN], str[2 * MAXN + 1];

pair <int, int> dpl[2 * MAXN], dpc[2 * MAXN];
int n;

inline void inter(int &l, int &r, int a, int b) {
    if(l > r) {
        cout << "NO";
        exit(0);
    }
    l = max(l, a);
    r = min(r, b);
}

inline void solve(pair <int, int> *dp, int h, char ch1, char ch2) {
    for(int i = 2 * n; i >= 1; i--) {
        int cur = 0;
        if(ch1 == str[i]) cur--;
        if(ch2 == str[i]) cur++;
        int l, r;
        if(i % 2 == 1) {
            l = 0, r = h + 1;
            inter(l, r, dp[i + 1].first, dp[i + 1].second);
            inter(l, r, dp[i + 1].first - cur, dp[i + 1].second - cur);
        }
        else {
            l = h + 1, r = 0;
            l = min(l, min(dp[i + 1].first, dp[i + 1].first - cur));
            r = max(r, max(dp[i + 1].second, dp[i + 1].second - cur));
        }
        inter(l, r, 1, h);
        dp[i] = {l, r};

    }
}

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, h, w, sl, sc;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> h >> w >> n;
    cin >> sl >> sc;
    cin >> s + 1 >> t + 1;

    for(i = 0; i < n; i++) {
        str[2 * i + 1] = s[i + 1];
        str[2 * i + 2] = t[i + 1];
    }

    dpl[2 * n + 1] = {1, h};
    dpc[2 * n + 1] = {1, w};

    solve(dpl, h, 'U', 'D');
    solve(dpc, w, 'L', 'R');

    if(dpl[1].first <= sl && dpl[1].second >= sl && dpc[1].first <= sc && dpc[1].second >= sc) {
        cout << "YES";
        return 0;
    }
    cout << "NO";

    return 0;
}



Measured memory_bytes: 7296
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function permutation(a,n)
	ans = Array{Int,1}[copy(a)]
	c = ones(Int,n)
	i = 1
	while i<=n
		if c[i]<i
			if i%2==1
				tmp = a[1]
				a[1] = a[i]
				a[i] = tmp
			else
				tmp = a[c[i]]
				a[c[i]] = a[i]
				a[i] = tmp
			end
			c[i] += 1
			i = 1
			push!(ans,copy(a))
		else
			c[i] = 1
			i += 1
		end
	end
	ans
end

function main()
	n,m,rn = readline() |> split |> parseMap
	r = readline() |> split |> parseMap
	d = 10^18*ones(Int,n,n)
	for i in 1:n
		d[i,i] = 0
	end
	for i in 1:m
		a,b,c = readline() |> split |> parseMap
		d[a,b] = c
		d[b,a] = c
	end
	for k in 1:n
		for i in 1:n
			for j in 1:n
				d[i,j] = min(d[i,j],d[i,k]+d[k,j])
			end
		end
	end
	prm = permutation(r,rn)
	minim = 10^18
	for i in 1:length(prm)
		x = 0
		for j in 2:rn
			x += d[prm[i][j-1],prm[i][j]]
		end
		minim = min(minim,x)
	end
	println(minim)
end
main()

Measured memory_bytes: 188672
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
priority_queue<pint> q;
bool cal()
{
	vector<pint> v,w;
	int n,su=0;string s;
	cin>>n;
	rep(i,n){
		cin>>s;int now=0,mi=0;
		rep(j,s.size()){
			if(s[j]=='(') now++;else now--;
			mi=min(now,mi);
		}
		if(now>=0) v.pb(mp(mi,now));
		else w.pb(mp(mi-now,now));
		su+=now;
	}
	sort(All(v));reverse(All(v));
	sort(All(w));
	if(su!=0) return false;
	int it=0,sum=0,m=v.size();
	rep(i,m){
		while(it<m && v[it].fi+sum>=0){
			q.push(mp(v[it].se,v[it].fi));it++;
		}
		if(q.empty()) return false;
		pint p=q.top();q.pop();
		sum+=p.fi;
	}
	rep(i,n-m){
		if(sum+w[i].fi+w[i].se<0) return false;
		sum+=w[i].se;
	}
	return true;
}
int main()
{
	if(cal()) cout<<"Yes"<<endl;else cout<<"No"<<endl;
}


Measured memory_bytes: 17056
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a+b<3){
    cout<<"Impossible"<<endl;
    return 0;
  } else if ( (a+b)%3 == 0){
    cout<<"Possible"<<endl;
    return 0;
  } else if (a%3 == 0 || b%3 == 0){
    cout<<"Possible"<<endl;
    return 0;
  }else {
    cout<<"Impossible"<<endl;
    return 0;
  }
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int main() {
	int h[2], m[2], s[2];
	rep(i, 3) {
		rep(i, 2) scanf("%d %d %d", &h[i], &m[i], &s[i]);
		int as = s[1] - s[0];
		int am = 0, ah = 0;
		if(as < 0) {
			as = 60 + as;
			am = -1;
		}
		am += m[1] - m[0];
		if(am < 0) {
			am = 60 + am;
			ah = -1;
		}
		ah += h[1] - h[0];
		printf("%d %d %d\n", ah, am, as);
	}
	return 0;
}

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

int main(){
    string str;
    bool flag;
    int cnt=0;

    while(getline(cin,str)){
        flag=true;

        for(int i=0;i<=str.length()/2;i++){
            if(str[i]!=str[str.length()-1-i]){
                flag=false;
                break;
            }
        }

        if(flag) cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k, x;
	cin >> k >> x;
	cout << (k * 500 >= x ? "Yes" : "No") << endl;
} 




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

using namespace std;

#define    VI       vector<int>
#define    VS       vector<string>
#define    LL       long long int
#define    ML       map<LL,LL>
#define    VLL      vector<LL>
#define    PB       push_back
#define    MP       make_pair
#define    FT       first
#define    SD       second
#define    PI       2*acos(0.0)
#define    F(i,a,n) for(int i=a;i<=n;i++)
#define    MS(a,v)  memset(a,v,sizeof(a));
#define    DEBUG    cout<<" I AM HERE "<<endl
#define    TC       int T;cin>>T;for(int TC=1;TC<=T;TC++)
#define    SORT(v)  sort(v.begin(),v.end())
#define    RSORT(v) sort(v.begin(),v.end(),greater<int>())
#define    FAST     ios_base::sync_with_stdio(false);cin.tie(NULL);
#define    mx       1000000
int main()
{
    FAST
    string s,t;
    cin>>s>>t;
    int sz=s.size();
    (t.substr(0,sz)==s)? cout<<"Yes"<<endl:cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3652
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse::<usize>().unwrap() - 1)
        .collect();

    let mut table = vec![vec![0; 200020]; 64];
    for i in 0..n {
        table[0][i] = a[i];
    }
    for i in 1..63 {
        for j in 0..n {
            table[i][j] = table[i - 1][table[i - 1][j]];
        }
    }

    let mut ans = 0;
    for i in (0..63).rev() {
        if k >> i & 1 == 1 {
            ans = table[i][ans];
        }
    }

    println!("{}", ans + 1);
}


Measured memory_bytes: 103324
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class arcD {
public:
    void solve(istream& in, ostream& out) {
        int H, W, N;
        in >> H >> W >> N;
        vector<int> a(N);
        for (int i = 0; i < N; ++i) {
            in >> a[i];
        }
        
        vector<vector<int>> grid(H, vector<int>(W, 0));
        for (int i = 0, k = 0; i < H; ++i) {
            if (i % 2 == 0) {
                for (int j = 0; j < W; ++j) {
                    if (a[k] == 0) {
                        ++k;
                    }
                    grid[i][j] = k + 1;
                    --a[k];
                }
            } else {
                for (int j = W - 1; j >= 0; --j) {
                    if (a[k] == 0) {
                        ++k;
                    }
                    grid[i][j] = k + 1;
                    --a[k];
                }
            }
        }
        
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                out << grid[i][j] << ' ';
            }
            out << '\n';
        }
    }
};


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

	arcD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(int x) {
	int cnt = 0;
	for (int i = 1; i <= x; i++) {
		if (i % 2 == 0) {
			continue;
		}

		if (x % i == 0) {
			cnt++;
		}

		if (cnt == 8) {
			return true;
		}
	}

	return false;
}

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

	int n;
	cin >> n;

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += solve(i);
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  cin>>n;
  int t=0,x=0,y=0;
  for(int i=0;i<n;i++){
    int nt,nx,ny;
    cin>>nt>>nx>>ny;
    int d=abs(nx-x)+abs(ny-y);
    //cout<<t<<" "<<d<<endl;
    if((nt-t)<d||((nt-t)-d)&1){
      cout<<"No"<<endl;
      return 0;
    }
    t=nt;x=nx;y=ny;
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

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

    int k;
    cin >> n >> k;
    int h[n];
    rep(i, n)   cin >> h[i];
    sort(h, h + n);
    
    int rem = h[k - 1] - h[0], tmp;
    //cout << rem << endl;
    FOR(i, 0, n - k + 1){
        tmp = h[i + k - 1] - h[i];
        rem = min(tmp, rem);
    }
    cout << rem << endl;
}

Measured memory_bytes: 640
N = int(input())

s = 1
while N > 26 ** s:
    N -= 26 ** s
    s += 1

ans = ""
N -= 1
for i in range(s)[::-1]:
    a = N // (26 ** i)
    N -= (26 ** i) * a
    ans += chr(ord("a") + a)
    
print(ans)

Measured memory_bytes: 9192
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int a, b;cin>>a>>b;
  int lower=max(25*a, 20*b);
  int upper=min(25*a+25, 20*b+20);
  if(lower>=upper){
    cout<<-1<<endl;
  }else{
    int ans=(lower+1)/2;
    if(ans*2<upper)cout<<ans<<endl;
    else cout<<-1<<endl;
  }
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 384
/* FALTU HI LIKH ... BUT KHALI NI BAITHNA */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define endl '\n'
#define int long long
#define ld long double
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define pii pair<int,int>
#define ff first
#define ss second
#define N (int)(2e5 + 10)

using namespace std;

list<int> adjList[N];
int par[N];

void bfs() {
	queue<int> q;
	q.push(1);

	while (!q.empty()) {
		int node = q.front();
		q.pop();

		for (int i : adjList[node]) {
			if (i != 1 and !par[i]) {
				par[i] = node;
				q.push(i);
			}
		}
	}
}

int32_t main() {
	fast
	int t_c = 1;
//	cin >> t_c;
	while (t_c--) {
//		cout << "#: ";
		int n, m;
		cin >> n >> m;
		for (int i = 0; i < m; i++) {
			int a, b;
			cin >> a >> b;
			adjList[a].pb(b), adjList[b].pb(a);
		}
		bfs();

		for (int i = 2; i <= n; i++)
			if (!par[i]) {
				cout << "No" << endl;
				return 0;
			}

		cout << "Yes" << endl;
		for (int i = 2; i <= n; i++)
			cout << par[i] << endl;
	}
}

Measured memory_bytes: 21788
#!/usr/bin/env python3
import sys
from fractions import gcd
input = sys.stdin.readline


class RgcdQ:
    def __init__(self, a):
        self.n = len(a)
        self.size = 2**(self.n - 1).bit_length()
        self.data = [0] * (2*self.size-1)
        self.initialize(a)

    # Initialize data
    def initialize(self, a):
        for i in range(self.n):
            self.data[self.size + i - 1] = a[i]
        for i in range(self.size-2, -1, -1):
            self.data[i] = gcd(self.data[i*2 + 1], self.data[i*2 + 2])

    # Update ak as x
    def update(self, k, x):
        k += self.size - 1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = gcd(self.data[2*k+1], self.data[2*k+2])

    # gcd value in [l, r)
    def query(self, l, r):
        L = l + self.size; R = r + self.size
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = gcd(s, self.data[R-1])
            if L & 1:
                s = gcd(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s
 
if __name__ == "__main__":
    n = int(input())
    a = [int(item) for item in input().split()]
    ST = RgcdQ(a)
    ans = 0
    for i in range(0, n):
        ans = max(ans, gcd(ST.query(0, i), ST.query(i+1, n)))
    print(ans)

Measured memory_bytes: 16124
#line 1 "main.cpp"
#include <stdio.h>
#line 1 "/home/ecasdqina/cpcpp/libs/library_cpp/data_structure/segment_tree.hpp"



#include <cstdint>
#include <vector>
#include <functional>

template<class Monoid>
class segment_tree {
public:
	using T = typename Monoid::value_type;
	using size_type = std::uint_fast32_t;

	using updator = std::function<T(T)>;
	using checker = std::function<bool(T)>;
	
private:
	const size_type size_;
	size_type height_;

public:
	std::vector<T> data;
	
private:
	const size_type get_height(size_type size) const {
		size_type height = 1;
		while(1 << height <= size) height++;
		return height;
	}
	const size_type base_size() const { return 1 << height_; }

	void meld(size_type index) {
		data[index] = Monoid::operation(data[index << 1 ^ 0], data[index << 1 ^ 1]);
	}

public:
	segment_tree() = default;
	segment_tree(segment_tree&&) = default;
	segment_tree(const segment_tree&) = default;
	
	segment_tree(size_type size)
		: size_(size) {
		height_ = get_height(size);
		data.assign(base_size() << 1, T{});
	}
	T fold(size_type left, size_type right) {
		T l_value = T{};
		T r_value = T{};

		for(left += base_size(), right += base_size();
			left < right;
			left >>= 1, right >>= 1) {
			if(left & 1)  l_value = Monoid::operation(l_value, data[left++]);
			if(right & 1) r_value = Monoid::operation(data[--right], r_value); 
		}
		return Monoid::operation(std::move(l_value), std::move(r_value));
	}

	void update(size_type index, const updator& update) {
		index += base_size();
		data[index] = update(data[index]);

		while(index >>= 1) meld(index);
	}
	void update(size_type index, const T& value) { update(index, [&value](const T& x) { return Monoid::operation(x, value); }); }
	void change(size_type index, const T& value) { update(index, [&value](const T& x) { return value; }); }
	
	const size_type search(size_type left, const checker& check) {
		T val = T{};
		size_type k = left + base_size();
		while(true) {
			if(check(Monoid::operation(val, data[k]))) {
				val = Monoid::operation(val, data[k]);
				if(k & 1) {
					if((k + 1) & k) k = (k + 1) >> 1;
					else return size();
				} else {
					k = k + 1;
				}
			} else {
				if(k < base_size()) {
					k = k << 1 ^ 0;
				} else {
					return k - base_size();
				}
			}
		}
	}
	
	const T operator[](size_type index) const { return data[index + base_size()]; }
	const size_type size() const { return size_; }
	const bool empty() const { return data.empty(); }
};

template<class T>
struct monoid {
	using value_type = T;

	static value_type operation(const value_type& a, const value_type& b) { return a + b; };
};

// @docs docs/segment_tree.md


#line 3 "main.cpp"

int main() {
	int n; scanf("%d", &n);

	printf("%d\n", 1 - n);
	return 0;
}


Measured memory_bytes: 1692
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        Console.WriteLine(s.Zip(s.Reverse(), (x, y) => x == y).Sum(x => x ? 0 : 1) / 2);
    }
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solve() {
    int n, w; cin >> n >> w;
    long long W[n + 1], V[n + 1];
    for (int i = 1; i <= n; i++) cin >> W[i] >> V[i];
    long long res[n + 1][w + 1];
    for (int i = 0; i < w + 1; i++) res[0][i] = 0;
    //for (int i = 0; i < n + 1; i++) res[i][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= w; j++) {
            res[i][j] = res[i - 1][j];
            if (j >= W[i])
                res[i][j] = max(res[i][j], res[i - 1][j - W[i]] + V[i]);
        }
    }
    cout << res[n][w];
}

int main()
{
    //rwFile();
    solve();
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,z=1;
    cin>>n;
    vec A(n+1),ans(n+1,0);
    rep(i,n+1) cin>>A[i];
    if(n==0){
        if(A[0]==1) cout<<1;
        else cout<<-1;
        return 0;
    }
    for(int i=n;i>=0;i--){
        if(i==n) ans[i]=A[i];
        else ans[i]=ans[i+1]+A[i];
    }
    rep(i,n+1){
        if(i==0) ans[i]=1;
        else if((ans[i-1]-A[i-1])*2<ans[i]) ans[i]=(ans[i-1]-A[i-1])*2;
    }
    ll sum=0;
    rep(i,n+1){
        if(i==0){
            if(A[i]) z=0;
        }
        else{
            if(ans[i]>ans[i-1]*2||ans[i]<ans[i-1]-A[i-1]) z=0;
        }
    }
    if(ans[n]!=A[n]) z=0;
    rep(i,n+1) sum+=ans[i];
    if(z) cout<<sum<<"\n";
    else cout<<-1<<"\n";
}

Measured memory_bytes: 4776
import java.util.*;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		int[] num = new int [5];
		for (int i=0;i<5;i++) {
			num[i] = sc.nextInt();
		}
		Arrays.sort(num);
		
		for (int i=num.length-1;i>=0;i--) {
			System.out.print(num[i]);
			if (i != 0)System.out.print(" ");
			else System.out.println();
		}
	}
	
	public static void main (String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      String S =sc.next();

      if(S.equals("SUN")){
      System.out.println(7);
      }
      else if(S.equals("MON")){
      System.out.println(6);
      }
      else if(S.equals("TUE")){
      System.out.println(5);
      }
      else if(S.equals("WED")){
      System.out.println(4);
      }
      else if(S.equals("THU")){
      System.out.println(3);
      }
      else if(S.equals("FRI")){
      System.out.println(2);
      }
      else if(S.equals("SAT")){
      System.out.println(1);
      }
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int n, countt = 0, a[100050], b[100050], sum1 = 0, sum2 = 0;
vector<int> inp, vec;

signed main() {

	cin >> n;

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

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

	for(int i = 0; i < n; i++){
		if(a[i] <= b[i]){
			b[i] -= a[i];
			a[i] = 0;
			a[i+1] = max(0LL, a[i+1] - b[i]);
			//cout << "first" << endl;
		}
		else{
			a[i] -= b[i];
			b[i] = 0;
			//cout << "sec" << endl;
		}

		//cout << b[i] << " ";

		sum2 += a[i];
	}

	sum2 += a[n];

	cout << sum1 - sum2 << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main() {
	int m;
	cin >> m;
	if (m % 2 == 0) {
		cout << m / 2 - 1;
	}
	if (m % 2 == 1) {
		cout << (m - 1) / 2;
	}
	return 0;
}

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

typedef struct{
	int num[6];
}saikoro;


saikoro s_1;

void n(saikoro *a){
	int tmp;
	tmp=a->num[4];
	a->num[4]=a->num[0];
	a->num[0]=a->num[1];
	a->num[1]=a->num[5];
	a->num[5]=tmp;
}

void s(saikoro *a){
	int tmp;
	tmp=a->num[1];
	a->num[1]=a->num[0];
	a->num[0]=a->num[4];
	a->num[4]=a->num[5];
	a->num[5]=tmp;
}

void e(saikoro *a){
	int tmp;
	tmp=a->num[2];
	a->num[2]=a->num[0];
	a->num[0]=a->num[3];
	a->num[3]=a->num[5];
	a->num[5]=tmp;
}

void w(saikoro *a){
	int tmp;
	tmp=a->num[3];
	a->num[3]=a->num[0];
	a->num[0]=a->num[2];
	a->num[2]=a->num[5];
	a->num[5]=tmp;
}

int main(){
	int i,num,slen;
	char input[128];
	
	fgets(input,sizeof input,stdin);
	sscanf(input,"%d %d %d %d %d %d",&s_1.num[0],&s_1.num[1]
		,&s_1.num[2],&s_1.num[3],&s_1.num[4],&s_1.num[5]);
	
	fgets(input,sizeof input,stdin);
	slen=strlen(input)-1;
	for(i=0;i<slen;i++){
		switch(input[i]){
			case 'N':
				n(&s_1);
			break;
			
			case 'S':
				s(&s_1);
			break;
			
			case 'E':
				e(&s_1);
			break;
			
			case 'W':
				w(&s_1);
			break;
		}
	}
	
	printf("%d\n",s_1.num[0]);
	return 0;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;
	cout << string(s.size(), 'x') << endl;
	return 0;
}

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

int main()
{
    ll N;
    cin>>N;
    ll a[N],b[N],c[N],A[N],B[N],C[N];
    for(ll i=0;i<N;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    A[0]=a[0]; B[0]=b[0]; C[0]=c[0];
    for(ll i=1;i<N;i++)
    {
        A[i] = a[i] + max(C[i-1],B[i-1]);
        B[i] = b[i] + max(A[i-1],C[i-1]);
        C[i] = c[i] + max(A[i-1],B[i-1]);
    }
    ll maxm=max(A[N-1],B[N-1]);
    maxm=max(maxm,C[N-1]);
    cout<<maxm;
}

Measured memory_bytes: 8284
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<double> v(N); for(auto& in:v) cin >> in;
    sort(v.begin(),v.end());
    res = v[0];
    for(int i = 1; i < N;i++){
        res = (res + v[i])/2;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <tuple>
#include <vector>

using namespace std;

namespace
{


struct Tree
{
	Tree(int numVertices)
	{
		al.resize(numVertices);
		w.resize(numVertices);
	}

	void addEdge(int a, int b, long long weight) {
		al[a].push_back(b);
		al[b].push_back(a);

		w[a].push_back(weight);
		w[b].push_back(weight);
	}

	void calcShortestPaths(int from);
	long long getShortestPath(int u, int v) const { return shp[u] + shp[v]; }

private :
	void dfs(int u, int p);

	std::vector<std::vector<int>> al;
	std::vector<std::vector<long long>> w;

	std::vector<long long> shp;
};

void Tree::calcShortestPaths(int from)
{
	shp.resize(al.size(), 0);
	dfs(from, -1);
}

void Tree::dfs(int u, int p)
{
	for (size_t i = 0; i != al[u].size(); ++i) {
		int nu = al[u][i];
		long long wnu = w[u][i];
		if (nu != p) {
			shp[nu] = shp[u] + wnu;
			dfs(nu, u);
		}
	}
}

}

int main()
{
	int n;
	std::cin >> n;
	Tree t(n);

	for (int i = 1; i < n; ++i) {
		int a, b;
		long long w;
		std::cin >> a >> b >> w;
		t.addEdge(a - 1, b - 1, w);
	}

	int q, k;
	std::cin >> q >> k;
	t.calcShortestPaths(k - 1);

	for (int i = 0; i != q; ++i) {
		int x, y;
		std::cin >> x >> y;
		std::cout << t.getShortestPath(x - 1, y - 1) << std::endl;
	}

	return 0;
}


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

#define _USE_MATH_DEFINES
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define remax(x, y) (x) = max((x), (y))
#define remin(x, y) (x) = min((x), (y))

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<int> a(N);
    forn(i, N)
        cin >> a[i];

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

    int h = 1, i = N - 1;
    while (i > 0 && h < a[i - 1]) {
        h++;
        i--;
    }

    if (i == 0 || h > a[i - 1]) {
        int delta = a[i] - h;
        if (delta & 1)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    } else if (h == a[i]) {
        int j = i;
        while (j > 0 && a[j - 1] == a[j])
            j--;
        int delta = i - j;
        if (delta & 1)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    } else {
        int j = i - 1;
        while (j > 0 && a[j - 1] == a[j])
            j--;
        if ((a[i] - h - 1) & 1 && (i - 1 - j) & 1)
            cout << "Second" << endl;
        else
            cout << "First" << endl;
    }
}


Measured memory_bytes: 640
#include<iostream>
#define N 100
using namespace std;
int main()
{
	int i;
	int j;
	int q;
	int n;
	int swap;
	int num[N];
	cin >> n;
	for (i = 0;i < n;i++)
	{
		cin >> num[i];
		if(i>0)
			cout << " ";
			cout << num[i];
	}
	cout << endl;
	for (i = 1;i < n;i++)
	{
		j = i;
		while (j > 0 && num[j] < num[j - 1])
		{
			swap = num[j];
			num[j] = num[j-1];
			num[j-1] = swap;
			j--;
		}
		for (q = 0;q < n;q++)
		{
			if (q > 0)
				cout << " ";
				cout << num[q];
		}
		if (i < n)
		{
			cout << endl;
		}
	}
    return 0;
}




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

class Number{
public:
	int n;		//本体
	int mod;	//mod10
	int after;	//１０の倍数にした
	Number(){}
	Number(int n){
		this->n = n;
		this->mod = n%10;
		if(this->mod == 0){
			this->after = n;
		}else{
			this->after = (n/10+1)*10;
		}
	} 
};

int main(){
	/*input*/
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e; 
	/*calculation*/
	Number x[5] = {a, b, c, d, e};
	int min = 0;
	for(int i = 0; i < 5; i++){
		if(x[i].mod){
			if(x[min].mod > x[i].mod){
				min = i;
			}
		}	
	}
	/*output*/
	int o = 0; 
	for(int i = 0; i < 5; i++){
		if(i == min){
			o+=x[i].n;
		}else{
			o+=x[i].after;
		}
	}
	cout << o << endl;
}


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

int n,rt,fa[N],a[2][N],vis[N];
struct graph{
	int tot,fst[N],pnt[N],nxt[N];
	void clr(){
		tot=0; memset(fst,0,sizeof(fst));
	}
	void add(int x,int y){
		pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
	}
}g0,g1;
int dfs(int x,int p){
	int i,y,u=0,v; a[p][x]=1;
	for (i=g0.fst[x]; i; i=g0.nxt[i]){
		y=g0.pnt[i];
		v=dfs(y,p); a[p][x]^=1;
		if (u){
			g1.add(u,v); g1.add(v,u); u=0;
		} else u=v;
	}
	if (a[p][x] && u){ g1.add(x,u); g1.add(u,x); u=0; }
	return u|(a[p][x]?x:0);
}
void solve(int p){
	int i;
	g0.clr();
	for (i=1; i<=n; i++){
		scanf("%d",&fa[i]);
		if (fa[i]==-1) rt=i; else g0.add(fa[i],i);
	}
	dfs(rt,p);
}
void dfs2(int x,int t){
	if (vis[x]) return; vis[x]=t;
	int i;
	for (i=g1.fst[x]; i; i=g1.nxt[i]) dfs2(g1.pnt[i],-t);
}
int main(){
	scanf("%d",&n);
	solve(0); solve(1);
	int i;
	for (i=1; i<=n; i++) if (a[0][i]!=a[1][i]){
		puts("IMPOSSIBLE"); return 0;
	}
	puts("POSSIBLE");
	for (i=1; i<=n; i++) if (a[0][i] && !vis[i]) dfs2(i,1);
	for (i=1; i<=n; i++) printf("%d%c",vis[i],i<n?' ':'\n');
	return 0;
}


Measured memory_bytes: 11904
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules ! vec_md { ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) } ; ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] } ; ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] } ; }

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

    let mut one = 0;
    let mut two = 0;
    let mut thr = 0;
    for i in 0..n {
        match a[i] {
            1 => one+=1,
            2 => two+=1,
            3 => thr+=1,
            _ => ()
        }
    }

    let mut dp = vec_md![None;301;301;301];
    println!("{}", rec(&mut dp,one,two,thr,n));
}

fn rec(dp: &mut Vec<Vec<Vec<Option<f64>>>>, i: usize, j: usize, k: usize, n: usize) -> f64 {
    if let Some(src) = dp[i][j][k] {
        return src;
    }
    if (i,j,k) == (0,0,0) {
        return 0.0;
    }

    let mut ret = 0.0;
    if i>=1 {ret += rec(dp,i-1,j,k,n) * i as f64;}
    if j>=1 {ret += rec(dp,i+1,j-1,k,n) * j as f64;}
    if k>=1 {ret += rec(dp,i,j+1,k-1,n) * k as f64;}
    ret += n as f64;
    ret /= (i + j + k) as f64;
    dp[i][j][k] = Some(ret);
    ret
}

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

#define Bye return 0
#define ll long long

void solve(){
    ll a, b, c, d; cin>>a>>b>>c>>d;

    ll area_1 = a*b;
    ll area_2 = c*d;

    cout<<(area_1>=area_2 ? area_1 : area_2)<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3552
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let x: f64 = input();
    let mut val = 100.0;
    let mut count = 0;
    while val < x {
        // println!("{}", val);
        val = (1.01 * val).trunc();
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// 最大公約数
ll gcd(ll m, ll n) {
  if (n==0) return abs(m);
  else return gcd(n, m%n);
}

// 最小公倍数
ll lcm(ll m, ll n) {
  return abs(m)/gcd(m, n)*abs(n);
}

int main() {
  int X;
  cin >> X;
  cout << lcm(X, 360)/X << endl;
  return 0;
}

Measured memory_bytes: 3592
N = int(input())
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print("hon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61640
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}
int dp[3001][3001];
void solve(string &s, int n)
{
	dp[n][0] = (s[n - 2] == '>') ? 1 : 0;
	dp[n][1] = (s[n - 2] == '<') ? 1 : 0;
	repD(i, n - 1, 2)
	{
		int total = n - i + 1;
		rep(g, total + 1)
		{
			if (g == 0)
			{
				if (i == n)	continue;
				dp[i][0] = 0;
				if (s[i - 2] == '<')
					continue;
				repA(j, 1, total)
				dp[i][0] = (dp[i][0] + dp[i + 1][total - j]) % mod;
			}
			else
			{
				if (s[i - 2] == '>')
					dp[i][g] = (mod+dp[i][g - 1] - dp[i + 1][g - 1]) % mod;
				else
					dp[i][g] = (dp[i][g - 1] + dp[i + 1][g - 1]) % mod;
			}
		}
	}
}
void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	memset(dp, -1, sizeof(dp));
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	solve(s, n);
	repD(gr, n - 1, 0)
	ans = (ans + dp[2][gr]) % mod;
	db1(ans);
}
int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 74032
using System;
using System.Collections.Generic;

namespace AtCoder
{
	public class Program
	{
		// ABC110-C
		static void Main(string[] args)
		{
			string result = "Yes";
			string S = Console.ReadLine();
			string T = Console.ReadLine();
			Dictionary<char, char> dicS = new Dictionary<char, char>();
			Dictionary<char, char> dicT = new Dictionary<char, char>();
			for (int i = 0; i < S.Length; i++) {
				char sc = S[i];
				char tc = T[i];
				if (!dicS.ContainsKey(sc)) {
					dicS[sc] = tc;
				}
				if (dicS[sc] != tc) {
					result = "No";
					break;
				}

				if (!dicT.ContainsKey(tc)) {
					dicT[tc] = sc;
				}
				if (dicT[tc] != sc) {
					result = "No";
					break;
				}
			}
			Console.WriteLine(result);
		}
	}
}


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

int main()
{
  ll n, x, y, ans, c=0, i, k;
   cin>>n>>k;
   if(n>=10)ans=k;
   else
   ans=k+(100*(10-n));
   cout<<ans<<endl;
}

Measured memory_bytes: 256