akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

struct vertex {
    vector<lint> edge;
    lint in;
    lint day;
};
vector<vertex> g;

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

    auto id = [&n](lint a,lint b) { return min(a, b) * n + max(a, b); };

    g.resize(n * n);
    for(lint i = 0; i < n; i++) {
        vector<lint> a(n-1);
        for(auto& e : a)  cin >> e, e--;

        auto it = begin(a);
        while(it+1 != end(a)) {
            lint v1 = id(i, *it);
            lint v2 = id(i, *++it);
            g[v1].edge.push_back(v2);
            g[v2].in++;
        }
    }

    queue<pair<lint, lint>> que; // id, day
    for(lint i = 0; i < n*n; i++) {
        if(g[i].in == 0)  que.push({i, 1});
    }

    while(!que.empty()) {
        lint id, day;
        tie(id, day) = que.front(); que.pop();
        g[id].day = day;
        for(auto& next : g[id].edge) {
            if(--g[next].in == 0)  que.push({next, day+1});
        }
    }

    lint res = 0;
    for(auto& e : g) {
        res = max(res, e.day);

        if(e.in) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << res << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;
  return 0;
}


Measured memory_bytes: 764
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,m;cin >> n >> m;
    vector<set<int>> v(n);
    rep(i, m) {
        int a,b;cin >> a >> b;
        a--;b--;
        v[a].insert(b);
        v[b].insert(a);
    }
    vector<int> k;
    for(int i = 2;i<=n;i++) k.pb(i);
    int count = 0;
    do {
        bool ok = true;
        rep(i, n-1) {
            if(i==0) {
                if(!v[0].count(k[0]-1)) ok=false;
            }
            else {
                if(!v[k[i-1]-1].count(k[i]-1)) ok=false;
            }
        }
        // for(auto p:k)cout << p << ' ';
        // cout << endl;
        if(ok)count++;
    } while(next_permutation(all(k)));
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<vector>
using namespace std; // 575

int main() {
	int N;
	static int b[100];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> b[i];
	vector<int> list;
	for (int i = 0;i < N;++ i) {
		if (b[i] > i + 1) {
			cout << -1;
			return 0;
		}
		list.insert(list.begin() + b[i] - 1, b[i]);
	}
	for (int i = 0;i < N;++ i) cout << list[i] << endl;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

各数字について自分より前に自分の値-1以上の個数があればとりあえず構築できる
次にどう構築するか考える
例えば
1. 1
2. 1 1
3. 1 1 1
4. 1 2 1 1
5. 1 2 2 1 1
6. 1 1 2 2 1 1
7. 1 2 1 2 2 1 1
8. 1 2 3 1 2 2 1 1
9. 1 2 2 3 1 2 2 1 1
できた
*/

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

using ll = long long;

int main() {
  while (true) {
    ll n, m, H, K;
    cin >> n >> m >> H >> K; // only 'H' and 'K' are capital
    if (n + m + H + K == 0) return 0;
    
    vector<vector<tuple<ll, ll, ll, ll>>> G(n); // to, cost, time, company
    
    for (int i = 0; i < m; i++) {
      ll a, b, c, h, r;
      cin >> a >> b >> c >> h >> r;
      a--;
      b--;
      r--;
      G[a].emplace_back(make_tuple(b, c, h, r));
      G[b].emplace_back(make_tuple(a, c, h, r));
    }
    
    ll s, t, p;
    cin >> s >> t >> p;
    s--;
    t--;
    
    vector<ll> d(p);
    vector<ll> k(p);
    for (int i = 0; i < p; i++) {
      ll l;
      cin >> l >> d[i];
      for (int j = 0; j < l; j++) {
        ll keep;
        cin >> keep;
        keep--;
        k[i] += (1 << keep);
      }
    }
    
    // bit DP
    vector<ll> dp_pass((1 << K), 1e18);
    dp_pass[0] = 0;
    for (int bit = 0; bit < (1 << K); bit++) {
      for (int i = 0; i < p; i++) {
        dp_pass[bit | k.at(i)] = min(dp_pass[bit | k.at(i)], dp_pass[bit] + d.at(i));
      }
    }
    
    // extended dijkstra
    ll ans = 1e18;
    for (int bit = 0; bit < (1 << K); bit++) {
      if (dp_pass[bit] == 1e18) continue;
      vector<vector<ll>> dp(n, vector<ll>(H + 1, 1e18)); // dp[i][j]: min cost at vertex i, rest time = j
      dp[s][H] = 0;
      priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>> pq; // cost, present position(vertex), rest time
      pq.push(make_tuple(0, s, H));
      while (!pq.empty()) {
        auto tmp = pq.top();
        ll cost = get<0>(tmp), now = get<1>(tmp), time = get<2>(tmp);
        pq.pop();
        if (dp[now][time] < cost) continue;
        for (int i = 0; i < G[now].size(); i++) {
          auto tmp = G[now][i];
          ll nto = get<0>(tmp), ncost = get<1>(tmp), ntime = get<2>(tmp), ncom = get<3>(tmp);
          if (bit & (1 << ncom)) {
            if (time >= ntime && dp[nto][time - ntime] > cost) {
              dp[nto][time - ntime] = cost;
              pq.push(make_tuple(cost, nto, time - ntime));
            }
          }
          else {
            if (time >= ntime && dp[nto][time - ntime] > cost + ncost) {
              dp[nto][time - ntime] = cost + ncost;
              pq.push(make_tuple(cost + ncost, nto, time - ntime));
            }
          }
        }
      }
      
      ll keep = 1e18;
      for (int j = 0; j <= H; j++) keep = min(keep, dp[t][j]);
      if (keep + dp_pass[bit] < ans) ans = min(ans, keep + dp_pass[bit]);
    }
    
    if (ans == 1e18) cout << -1 << '\n';
    else cout << ans << '\n';
  }
}


Measured memory_bytes: 3356
# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	ai = [int(input()) for i in range(N)]
	
	now = 1
	count = 0
	for i in range(N):
		count = count + 1
		now = ai[now-1]
		if now == 2:
			print(count)
			exit()
	print(-1)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 7084
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    x = ini()
    a = x // 500
    ans = a * 1000
    x %= 500
    b = x // 5
    ans += b * 5
    debug(a, b)
    return ans


print(solve())


Measured memory_bytes: 9192
def slove():
    import sys
    import copy
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    x = list(map(int, input().rstrip('\n').split()))
    xl = copy.deepcopy(x)
    xl.sort()
    a = xl[n // 2-1]
    b = xl[n // 2]
    for i in range(n):
        if x[i] <= a:
            print(b)
        elif b <= x[i]:
            print(a)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 119808
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(Integer.parseInt(sc.next()));
        }
        System.out.println(set.size());
    }
}


Measured memory_bytes: 21844
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    vector< vector<int> > x(n), y(n);
    rep(i, n){
        cin >> a[i];
        rep(j, a[i]){
            int t, u;
            cin >> t >> u;
            x[i].emplace_back(--t);
            y[i].emplace_back(u);
        }
    }

    int ans = 0;
    rep(i, 1 << n){
        int cnt = 0;
        bool ok = true;
        rep(j, n){
            if(i >> j & 1){
                ++cnt;
                rep(k, a[j]){
                    if(y[j][k] != (i >> x[j][k] & 1)){
                        ok = false;
                        break;
                    }
                }
            }
        }
        if(ok){
            chmax(ans, cnt);
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    H = int(input())

    memo = {}
    def dfs(h):
        if h in memo:
            return memo[h]
        if h == 1:
            memo[1] = 1
            return 1

        ret1 = dfs(h//2)
        ret2 = dfs(h//2)
        memo[h] = ret1 + ret2 + 1
        return memo[h]

    ans = dfs(H)
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b+c == 2 * max({a, b, c}))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int ascending(const int *a, const int *b){
  return(*a - *b);
}

  int n,q;
  int S[100000];
  int T[50000];
  int C = 0;

  int solve(int mid,int key){
    if(T[mid] >= key){
      return 1;
    }else{
      return 0;
    }
  }

  int binary_search(int key){
    int ok = q;
    int ng = -1;
    while( abs (ok - ng) > 1){
      int mid = (ok + ng) / 2;
      if(solve(mid,key) == 1){
        ok = mid;
      }else{
        ng = mid;
      }
    }
    if(T[ok] == key){
      C ++;
    }
  }

int main(){

  scanf("%d",&n);
  for(int i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(int i=0; i<n; i++){
    scanf("%d",&T[i]);
  }

  qsort(T,q,sizeof(int),ascending);
  qsort(S,n,sizeof(int),ascending);  

  for(int i=0; i<n; i++){
    if(i == 0){
      binary_search(S[i]);
    }else{
      if( S[i] > S[i-1] ){
        binary_search(S[i]);
      }
    }
  }

  printf("%d\n",C);

  return 0;
}


Measured memory_bytes: 2360
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int N = 17;
const int MAXS = (1 << 16) + 5;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}
inline void Dec(int &x, int y) {
	x -= y; if (x < 0) x += MOD;
}
inline int Add(int x, int y) {
	Inc(x, y); return x;
}
inline int Sub(int x, int y) {
	Dec(x, y); return x;
}
inline int Mul(int x, int y) {
	return 1LL * x * y % MOD;
}

}
using namespace ModCalculator;

inline int ksm(int x, int k) {
	int ret = 1;
	while (k) {
		if (k & 1) ret = Mul(ret, x);
		x = Mul(x, x);
		k >>= 1;
	}
	return ret;
}

int n, m, a[N];
int fac[MAXS], finv[MAXS];
int S, bit[MAXS], dp[2][MAXS];

inline int C(int x, int y) {
	if (x < y) return 0;
	return Mul(fac[x], Mul(finv[y], finv[x - y]));
}

void init() {
	read(n); read(m);
	for (int i = 1; i <= m; ++i) {
		read(a[i]);
	}
	S = (1 << n);
	fac[0] = 1;
	for (int i = 1; i <= S; ++i) {
		fac[i] = Mul(fac[i - 1], i);
	}
	finv[S] = ksm(fac[S], MOD - 2);
	for (int i = S - 1; i >= 0; --i) {
		finv[i] = Mul(finv[i + 1], i + 1);
	}
}

void solve() {
	sort(a + 1, a + m + 1);
	reverse(a + 1, a + m + 1);
	int pre = 0, cur = 1;
	dp[0][0] = 1;
	for (int i = 1; i <= m; ++i) {
		mset(dp[cur], 0);
		for (int s = 0; s < S; ++s) {
			int x = dp[pre][s];
			if (!x) continue;
			Inc(dp[cur][s], x);
			int t = S - 1 - s;
			for (int j = 0; j < n; ++j) {
				if ((t >> j) & 1) {
					Inc(dp[cur][s | (1 << j)], Mul(x, Mul(C(t - a[i] + 1, (1 << j) - 1), fac[1 << j])));
				}
			}
		}
		swap(pre, cur);
	}
	int ans = 0;
	for (int i = 0; i < S; ++i) {
		bit[i] = bit[i >> 1] + (i & 1);
		int tmp = Mul(dp[pre][i], fac[S - 1 - i]);
		(bit[i] & 1)? Dec(ans, tmp) : Inc(ans, tmp);
	}
	printf("%d\n", Mul(ans, S));
}

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



Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        string S = cin.nextString();
        int a = -1;
        int b = -1;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == 'A' && a == -1)
            {
                a = i;
            }
            else if (S[i] == 'C' && b == -1)
            {
                b = i;
            }
            else
            {
                if (!Char.IsLower(S[i]))
                {
                    Console.WriteLine("WA");
                    return;
                }
            }
        }

        if (a != 0)
        {
            Console.WriteLine("WA");
            return;
        }

        if (!(2 <= b && b <= S.Length - 2))
        {
            Console.WriteLine("WA");
            return;
        }

        Console.WriteLine("AC");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
	string s;
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		char a;
		cin >> s;
		char t = '~';
		for(int j = 0; j < s.length(); ++j){
			a = s[j];
			switch(a){
				case '1':
					if(t == '~' || t == ' '){
						t = '.';
					}else if(t == '.'){
						t = ',';
					}else if(t == ','){
						t = '!';
					}else if(t == '!'){
						t = '?';
					}else if(t == '?'){
						t = ' ';
					}
					break;
				case '2':
					if(t == '~' || t == 'c'){
						t = 'a';
					}else{
						t++;
					}
					break;
				case '3':
					if(t == '~' || t == 'f'){
						t = 'd';
					}else{
						t++;
					}
					break;
				case '4':
					if(t == '~' || t == 'i'){
						t = 'g';
					}else{
						t++;
					}
					break;
				case '5':
					if(t == '~' || t == 'l'){
						t = 'j';
					}else{
						t++;
					}
					break;
				case '6':
					if(t == '~' || t == 'o'){
						t = 'm';
					}else{
						t++;
					}
					break;
				case '7':
					if(t == '~' || t == 's'){
						t = 'p';
					}else{
						t++;
					}
					break;
				case '8':
					if(t == '~' || t == 'v'){
						t = 't';
					}else{
						t++;
					}
					break;
				case '9':
					if(t == '~' || t == 'z'){
						t = 'w';
					}else{
						t++;
					}
					break;
				case '0':
					if(t != '~'){
						cout << t;
						t = '~';
					}
					break;
			}
		}
		cout << endl;
	}
}


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

#define rep(i, a, n) for (int i = a; i < n; i++)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N, M, ans = 0;
  cin >> N;
  vector<int> T(N, 0);
  rep(i, 0, N) {
    cin >> T[i];
    ans += T[i];
  }
  cin >> M;
  rep(i, 0, M) {
    int p, x;
    cin >> p >> x;
    cout << ans - (T[p - 1] - x) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b + c > a)
    {
        cout << b + c - a << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 2e5 + 10 , N = 2e6 + 10 , SQ = 320 , base = 1999 , mod = 1e9 + 7 , INF = -1e18 , lg = 33;

int32_t main() {
    FAST
    int n;
    cin >> n;
    int tot = 1;
    for (int i = 0; i < n; ++i) {
        tot = (tot * 10) % mod;
    }
    int bad = 1 , good = 1;
    for (int i = 0; i < n; ++i) {
        bad = (bad * 9) % mod;
        good = (good * 8) % mod;
    }
    bad = (bad * 2) % mod;
    // cout << tot << ' ' << good << ' ' << bad << endl;
    cout << (tot + good - bad + mod) % mod << '\n';
}


Measured memory_bytes: 3644
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) REV(SORT(V)) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) for(int i = 0; i < (V).size(); i++) {cout << (V).at(i) << endl;}

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN(n);
  Vd v(n);
  VIN(v)
  double tmp = 0;
  REP(i,n) {
    tmp += 1/(v[i]);
  }
  OUT(1/tmp);
}

Measured memory_bytes: 256
def gcd(x, y):
    if y==0:
        return x
    else:
        return gcd(y, x%y)

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = [int(input()) for i in range(n)]
r = 1
for i in a:
    r = lcm(r, i)
print(r)


Measured memory_bytes: 3316
import java.io.BufferedReader
import java.io.PrintWriter
var out: PrintWriter = PrintWriter(System.out)  // これを使って出力すると早い

fun main(args: Array<String>) {
    val ab = MyScanner.readAsIntArray()
    out.println(if (ab[0] <= 8 && ab[1] <= 8) "Yay!" else ":(")

    out.flush() // 消さない
}

/**
 * 読み取り
 */
class MyScanner {
    companion object {
        private var reader : BufferedReader = System.`in`.bufferedReader()

        fun reset(){
            reader = System.`in`.bufferedReader()
        }

        fun readAsInt(): Int {
            return Integer.parseInt(reader.readLine())
        }

        // Int
        fun readAsIntArray(delimiters: String = " "): IntArray {
            return reader
                .readLine()
                .split(delimiters)
                .map { s -> Integer.parseInt(s) }
                .toIntArray()
        }

        fun readNTimesAsInt(n: Int): IntArray {
            return (1..n).map { readAsInt() }.toIntArray()
        }

        fun readNTimesAsIntArray(n: Int): Array<IntArray> {
            return (1..n).map { readAsIntArray() }.toTypedArray()
        }

        // long
        // TODO 別の方法を考える
        fun readAsLong(): Long {
            return reader.readLine().toLong()
        }

        fun readAsLongArray(delimiters: String = " "): LongArray {
            return reader.readLine()
                .split(delimiters)
                .map { s -> s.toLong() }
                .toLongArray()
        }

        fun readNTimesAsLong(n: Int): LongArray {
            return (1..n).map { readAsLong() }.toLongArray()
        }

        fun readAsString(): String {
            return reader.readLine()
        }

        fun readAsStringArray(delimiters: String = " "): Array<String> {
            return readAsString().split(delimiters).toTypedArray()
        }

    }
}

/**
 * 要素とその個数を出力
 */
fun <T> Array<T>.ofCountMap(): Map<T, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

/**
 * 文字とその個数を出力
 */
fun String.ofCountMap(): Map<Char, Int> {
    return this.toCharArray().ofCountMap()
}

/**
 * 文字とその個数を出力
 */
fun CharArray.ofCountMap(): Map<Char, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

Measured memory_bytes: 35776
#include <stdio.h>

int main(void){

  int N, K;
  scanf("%d %d",&N,&K);
  int h[N], i;
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  int j, count=0;
  for(j=0;j<N;j++){
    if(h[j]>=K){
      count+=1;
    }
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
int n,u,v;
vi g[N];
ll dp[N][2];

ll solve(int curr, int par, int color) {
	if(dp[curr][color] != -1) return dp[curr][color];

	ll ret = 1;

	for(auto next : g[curr]) {
		if(next != par) {
			if (color == 0)
			{
				ret *= (solve(next, curr, 0) + solve(next, curr, 1))%MOD;
				ret %= MOD;
			} else {
				ret *= solve(next, curr, 0);
				ret %= MOD;
			}
		}
	}

	return dp[curr][color] = ret;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;

    memset(dp, -1, sizeof(dp));
    F(i, 0, n-1) {
    	cin>>u>>v;
    	u--; v--;
    	g[u].push_back(v);
    	g[v].push_back(u);
    }

    cout<<(solve(0, -1, 0) + solve(0, -1, 1))%MOD;

    return 0;
}/*

*/

Measured memory_bytes: 15616
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define MN 100005
using namespace std;
inline ll in(){
    ll x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
ll a[MN];
ll tot,sum,num,n,d,pos,cnt;
inline ll bis(ll x){
	ll l=0,r=num,res=0;
	while (l<=r){
		ll mid=(l+r)>>1;
		if ((ll)(num-mid-(n-1ll)*mid)>=x) res=mid,l=mid+1;
		else r=mid-1;
	}return res;
}
int main()
{
	n=in();tot=(1ll*(n+1)*n)>>1;
	for (int i=1;i<=n;++i) a[i]=in(),sum+=1ll*a[i];a[0]=a[n];
	if (sum%tot) {printf("NO");return 0;}num=sum/tot;
	for (int i=1;i<=n;++i){
		d=a[i]-a[i-1];pos=bis(d);
		if (d!=(1ll*num-pos-(n-1ll)*pos)) {printf("NO");return 0;}
		cnt+=pos;
	}printf((cnt==num)?"YES":"NO");return 0;
}

Measured memory_bytes: 896
n, x = list(map(int, input().split()))
llist = list(map(int, input().split()))
kai = 0
tsumu = 0
while tsumu <= x and llist != [] :
    kai += 1
    tsumu += llist.pop(0)
else :
    if tsumu <= x :
        kai += 1
print(kai)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
double x,y;
bool input(){
cin>>x>>y;
return (x!=0)||(y!=0);
}
double solve(){
double tmp = sqrt((x/2)*(x/2)+y*y);
return (x*x) + 4* x*tmp/2;
}
int main(){
while(input()){
cout<<setprecision(100)<<solve()<<endl;
}
}

Measured memory_bytes: 1276
#include<iostream>

using namespace std;

int main()
{
	int num, a, b, c;
		while(cin >> num , num)
		{
			for(int i = 0; i < num; i++)
			{
				cin >> a >> b >> c;

				if(a == 100 || b == 100 || c == 100 || (a+b)/2 >= 90 || (a+b+c)/3 >= 80)
				{
					cout << "A" << endl;
				}
				else if((a+b+c)/3 >= 70 || (a+b+c)/3 >= 50 && a >= 80 || b >= 80)
				{
					cout << "B" << endl;
				}
				else
				{
					cout << "C" << endl;
				}
			}
		}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
#define int long long int
using namespace std;
int s[123456];
int dp[123][123456];
signed main()
{
	fastScan;
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	dp[0][0]=1;
	int mod=(int)(1e9+7);
	for(int i=1;i<=n;i++)
	{
		int pre=0;
		for(int j=0;j<=k;j++)
		{
			pre+=dp[i-1][j];
			if(j-s[i]-1>=0)
				pre-=dp[i-1][j-s[i]-1];
			pre=(pre%mod+mod)%mod;
			dp[i][j]=pre;
		}
	}
	cout<<dp[n][k]<<nl;
}


Measured memory_bytes: 99456
import sys
import math


def solve(a: int, b: int, x: int):
    V = a * a * b
    if x * 2 > V:
        y = x / (a*a*0.5) - b
        print(math.atan2(b-y, a)/math.pi*180)
    else:
        y = x / (a*b*0.5)
        print(math.atan2(b, y)/math.pi*180)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    ans = solve(a, b, x)
    if ans is not None:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#define rep(i,n) for(int i=0; i<=(n); i++)
using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  
  rep(i,x){
    if(i*2 + (x-i)*4 == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

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

	deque <int> deq;
	int n, t;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> t;
		if (i % 2 == 0)
		{
			deq.push_back(t);
		}
		else
		{
			deq.push_front(t);
		}
	}

	if (n % 2 == 0)
	{
		while (!deq.empty())
		{
			int x = deq.front();
			deq.pop_front();
			cout << x << ' ';
		}
		cout << '\n';
	}
	else
	{
		while (!deq.empty())
		{
			int x = deq.back();
			deq.pop_back();
			cout << x << ' ';
		}
		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

long long dp[101][100001];
constexpr long long MOD = 1000000007;
int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int i = 0; i <= a[0]; i++) {
    dp[0][i] = 1;
  }

  for (int i = 1; i < N; i++) {
    long long sum = 0;
    for (int k = 0; k <= K; k++) {
      sum = (sum + dp[i - 1][k]) % MOD;
      // cerr << k << " " << sum << endl;
      if (k - a[i] - 1 >= 0) sum = (sum + MOD - dp[i - 1][k - a[i] - 1]) % MOD;
      // for (int j = 0; j <= a[i]; j++) {
      //   if (k - j < 0) break;
      //   dp[i][k] += dp[i - 1][k - j];
      // }
      dp[i][k] = sum;
    }
  }
  // for (int i = 0; i < N; i++){
  //   for (int k = 0; k <= K; k++) {
  //     cerr << dp[i][k] << " ";
  //   }cerr << endl;
  // }

  cout << dp[N - 1][K] << endl;

  return 0;
}

Measured memory_bytes: 78336
n, m = map(int, input().split())
h = list(map(int, input().split()))

hantei = [1]*n

for i in range(m):
    data = list(map(int, input().split()))

    if h[data[0]-1] < h[data[1]-1]:
        hantei[data[0]-1] = 0
    elif h[data[0]-1] > h[data[1]-1]:
        hantei[data[1]-1] = 0
    else:
        hantei[data[0]-1] = 0
        hantei[data[1]-1] = 0

print(sum(hantei))

Measured memory_bytes: 20124
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int, int>
#define ld long double
const int mod = 1e9 + 7;
 
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
 
 

int dp[100007];
 
 
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 

 

int n,w;
cin>>n>>w;

 
 vector<int>wt(n+1),val(n+1);
 for(int i=1;i<=n;i++)
 {
	 cin>>wt[i]>>val[i];
 }


  
    dp[0] = 0;
    for(int i=1;i<=n;i++){
        for(int j=w;j>=wt[i]; j--){
            dp[j] = max(dp[j - wt[i]] + val[i], dp[j]);
        }
    }
    cout<<dp[w]<<"\n";



 

 
}

Measured memory_bytes: 1024
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void A(){
    ll k,a,b; cin >> k >> a >> b;
    ll i = k;
    while(i<a){
        i+=k;
    }

    if(i<=b) cout << "OK" << endl;
    else           cout << "NG" << endl;
    
}
void B(){
    ll x; cin >> x;
    ll sum = 100;
    ll i = 0;
    while(sum<x){
        sum *=1.01;
        i++;
    }
    cout << i << endl;
    
}

void C(){

}

void D(){
    ll a,b,n; cin >> a >> b >> n;
    cout << (a*min((b-1),n))/b << endl;
}
void e(){}

int main(){
    B();
    return 0;
}

Measured memory_bytes: 3528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    ll n,m; cin>>n>>m;
    vector<ll>h(n);
    rep(i,n)cin>>h[i];
    Graph G(n);
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll ans=0;
    ll mx;
    bool jud;
    rep(i,n){
        jud=true;
        for(auto v:G[i]){
            if(h[v]>=h[i]){
                jud=false;
            }
        }
        if(jud)ans++;
    }
    cout<<ans<<endl;
}








Measured memory_bytes: 9068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input();
		var m = p[1].ToInt();
		var n = p[0].ToLong();
		var a = Input().ToInt();
		long wa = 0;
		for(int i = 0; i < m; i++)
		{
			wa += a[i];
		}
		if(n - wa < 0)
		{
			Console.WriteLine(-1);
		}
		else
		Console.WriteLine(n - wa);
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

typedef long long int ll;

void Pre(vector<tuple<ll,ll,ll,ll,ll> > &idlr, ll node = 0)
{
    cout << " " << get<0>(idlr[node]);
    if(get<1>(idlr[node]) != -1){
        Pre(idlr, get<1>(idlr[node]));
    }
    if(get<2>(idlr[node]) != -1){
        Pre(idlr, get<2>(idlr[node]));
    }
}

void Ino(vector<tuple<ll,ll,ll,ll,ll> > &idlr, ll node = 0)
{
    if(get<1>(idlr[node]) != -1){
        Ino(idlr, get<1>(idlr[node]));
    }

    cout << " " << get<0>(idlr[node]);

    if(get<2>(idlr[node]) != -1){
        Ino(idlr, get<2>(idlr[node]));
    }
}

void Pos(vector<tuple<ll,ll,ll,ll,ll> > &idlr, ll node)
{
    if(get<1>(idlr[node]) != -1){
        Pos(idlr, get<1>(idlr[node]));
    }
    
    if(get<2>(idlr[node]) != -1){
        Pos(idlr, get<2>(idlr[node]));
    }

    cout << " " << get<0>(idlr[node]); 
}

int main()
{
    ll n;
    cin >> n;
    vector<tuple<ll,ll,ll,ll,ll> > idlr(n);//0id 1l 2r 3p 4s
    for(ll i = 0;i < n;i++){
        cin >> get<0>(idlr[i]) >> get<1>(idlr[i]) >> get<2>(idlr[i]);
    }

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

    for(ll i = 0;i < n;i++){
        if(get<1>(idlr[get<0>(idlr[i])]) != -1){
            get<3>(idlr[get<1>(idlr[get<0>(idlr[i])])]) = get<0>(idlr[i]);
            get<4>(idlr[get<1>(idlr[get<0>(idlr[i])])]) = get<2>(idlr[get<0>(idlr[i])]);
        }
        if(get<2>(idlr[get<0>(idlr[i])]) != -1){
            get<3>(idlr[get<2>(idlr[get<0>(idlr[i])])]) = get<0>(idlr[i]);
            get<4>(idlr[get<2>(idlr[get<0>(idlr[i])])]) = get<2>(idlr[get<0>(idlr[i])]);
        }
    }

    ll root;
    for(ll i = 0;i < n;i++){
        if(get<3>(idlr[i]) == 0 && get<4>(idlr[i]) == 0){
            root = get<0>(idlr[i]);
        }
    }

    cout << "Preorder\n";
    Pre(idlr, root);
    cout << "\nInorder\n";
    Ino(idlr, root);
    cout << "\nPostorder\n";
    Pos(idlr, root);
    cout << "\n";
 
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
//素数判定
bool is_prime(long long n){
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
    ll N;
    cin >> N;
    int A[N+1];
    rep(i,N+1){
        cin >> A[i];
    }
    int B[N];
    rep(i,N){
        cin >> B[i];
    }
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(B[i]>=A[i]+A[i+1]){
            ans += A[i] + A[i + 1];
            A[i] = 0;
            A[i + 1] = 0;
        }else if(B[i]>=A[i]&&B[i]<A[i]+A[i+1]){
            ans += B[i];
            A[i + 1] = A[i+1]-(B[i] - A[i]);
            A[i] = 0;
        }else if(B[i]<A[i]){
            ans += B[i];
            A[i] -= B[i];
        }
        //cout << "A[i]=" << A[i] << endl;
        //cout << "A[i+1]=" << A[i+1] << endl;
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 123456*2;
bool prime[MAX_N+1];
ll pn[MAX_N];

void make_prime (void )
{
	rep (i, MAX_N+1 ) prime[i] = true;

	prime[0] = false;
	prime[1] = false;

	for (int i = 2; i <= MAX_N; i++ ){
		if (prime[i] ){
			for (int j = 2*i; j <= MAX_N; j += i ){
				prime[j] = false;
			} // end for
		} // end if
	} // end for

	memset (pn, 0LL, sizeof (pn ) );
	ll cnt = 0LL;
	for (int i = 0; i <= MAX_N; i++ ){
		if (prime[i] ){
			cnt++;
		} // end if
		pn[i] = cnt;
	} //end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.Chebyshevs_Theorem", "r", stdin );
	make_prime ();
	int n;
	while (scanf ("%d", &n ), n ){
		ll ans = pn[2*n] - pn[n];
		printf ("%d\n", ans );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 3364
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      Boolean[][] checkCards = new Boolean[4][13];
      for( int i = 0; i < 4; i++ ) {
        Arrays.fill(checkCards[i], false);
      }
      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int a,b;

      for(int i = 0; i < n; i++) {
        lines = br.readLine().split(" ");
        a = suitToInt(lines[0]);
        b = Integer.parseInt(lines[1]);
        checkCards[a][b-1] = true;
      }

      for(int i = 0; i < 4; i++ ) {
        for( int j = 0; j < 13; j++ ) {
          if(!checkCards[i][j]) System.out.println(intToSuit(i) + " " + (j+1));
        }
      }
    }
  }

  public static int suitToInt( String suit ) {
    switch( suit ) {
      case "S": return 0;
      case "H": return 1;
      case "C": return 2;
      default : return 3;
    }
  }
  public static String intToSuit( int r ) {
    switch( r ) {
      case 0  : return "S";
      case 1  : return "H";
      case 2  : return "C";
      default : return "D";
    }
  }
}


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

signed main(){

  int p,q; cin >> p >> q;

  int ans = q / __gcd(p,q);
  map<int,int> mp;
  for(int i = 2; i*i <= ans; i++){
    while(ans%i == 0){
      mp[i]++;
      ans /= i;
    }
  }
  if(ans != 1) mp[ans] = 1;

  int res = 1;
  for(auto p : mp){
    if(p.second > 0) res *= p.first;
  }
  cout << res << endl;

  return 0;
}



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

bool prime(int n) {
  if (n < 2) return false;
  else if (n == 2) return true;
  else if (n % 2 == 0) return false;
  double sqrtn = sqrt(n);
  for (int i=3;i<=sqrtn;i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  int n, ans, now;
  cin>>n;
  if (n % 2 == 0) now = n+1;
  else now = n;
  if (n == 2) cout<<2<<endl;
  else {
  for (int i=now;i<110000;i += 2) {
    if (prime(i) == true) {
      ans = i;
      break;
    }
  }
  cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, k;
  int a[500], b[500];
  long long S = 0;
  
  scanf("%d %d", &n, &k);
  
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    S += a[i];
  }
  
  vector<long long> div;
  for (long long i = 1; i * i <= S; i++) {
   	if (S % i == 0) {
      div.push_back(i);
      if (i != S / i) div.push_back(S / i);
    }
  }
  
  sort(div.rbegin(), div.rend());
  
  for (int i = 0; i < div.size(); i++) {
    for (int j = 0; j < n; j++) {
      b[j] = a[j] % div[i];
    }
    sort(b, b + n);
    long long cnt1 = 0, cnt2 = 0;
    for (int j = 0; j < n; j++) {
      if (cnt1 + b[j] <= k) cnt1 += b[j];
      else cnt2 += (div[i] - b[j]) % div[i];
    }
    if (max(cnt1, cnt2) <= k) {
      printf("%lld\n", div[i]);
      break;
    }
  }
  
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    string S;
    cin >> S;

    int pos = 15-S.size();
    int win = 0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='o')win++;
    }

    if(win+pos>=8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}



Measured memory_bytes: 256
import Control.Applicative

main :: IO ()
main = do
  xs <- (map read . words) <$> getLine
  putStrLn $ solve xs

solve :: [Int] -> String
solve xs
  | ((xs !! 0) < (xs !! 1)) && ((xs !! 1) < (xs !! 2)) = "Yes"
  | otherwise = "No"

Measured memory_bytes: 3448