akhauriyash/Code-Regression huggingface dataset:
use std::cmp::min;
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)*}
    };
}

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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

fn main() {
    input! {
    s: [usize; 5]
    }
    let mut ans = 0;
    let mut d = 10;
    for i in 0..5{
        ans += if s[i] % 10 == 0 {s[i]} else { (s[i] / 10 + 1) * 10 };
        if s[i] % 10 != 0{
            d = min(d, s[i] % 10)
        }
    }
    ans = ans - 10 + d;
    println!("{}", ans);
}



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

int main()
{
    int i,n,x,cnt=0;
    cin>> n ;
    for(i=1;i<=n;i++){
        cin>> x;
        if((i&1) && (x&1))cnt++;
    }
    cout<< cnt <<endl;
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int a[110], cnt[10];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) {
        int x; cin >> x;
        cnt[min(x, 3200)/400]++;
    }

    int m = 0;
    for (int i=0;i<8;i++) m += cnt[i]>0;
    cout << max(m, 1) << " " << m+cnt[8] << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
    #define int long long
    #define endl '\n'
    ///Yeah, I am the backupguy!
    using namespace std;
    int32_t main()
    {
    iostream::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    cout<<min((n%m),abs((n%m)-m));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int h, w, d; cin >> h >> w >> d;
    vec<array<int, 2>> field(h * w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int a; cin >> a;
            field[a - 1] = { i, j };
        }
    }

    vvec<int> sum(d);
    for (int i = 0; i < d; ++i) {
        sum[i].push_back(0);
        for (int j = i + d; j < h * w; j += d) {
            int dist = abs(field[j][0] - field[j - d][0]) + abs(field[j][1] - field[j - d][1]);
            sum[i].push_back(sum[i].back() + dist);
        }
    }

    int q; cin >> q;
    while (q--) {
        int l, r; cin >> l >> r;
        int idx = l % d - 1 < 0 ? d - 1 : l % d - 1;

        int ridx = r % d == 0 ? r / d - 1 : r / d;
        int lidx = l % d == 0 ? l / d - 1 : l / d;
        cout << sum[idx][ridx] - sum[idx][lidx] << endl;
    }
}



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

const int INF = 100000000;

int main() {
  int N, L;
  cin >> N >> L;
  int whole_taste = 0;
  for (int i = 0; i < N; i++) {
    whole_taste += L + i;
  }
  int dmin = INF;
  int ans;
  for (int i = 0; i < N; i++) {
    int apple_taste = L + i;
    int pai_taste = whole_taste - apple_taste;
    int d = abs(whole_taste - pai_taste);
    if (d < dmin) {
      dmin = d;
      ans = pai_taste;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int dy[] = {1,0};
int dx[] = {0,1};
 
struct UnionFind{
    vector<int> data;
    int __size;
    UnionFind(int sz) {
    data.assign(sz, -1);
    __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  bool same(int x, int y){
      return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
 
  int unum() {
    return (__size);
  }
};
 
int main(){ 
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  map<int,ll> mp;
  UnionFind uf(h*w);
  vector<int> b; 
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = 0; k < 2; k++) {
        int ny = i + dy[k], nx = j + dx[k];
        if (ny >= h || nx >= w) continue;
        if (uf.same(i*w+j,ny*w+nx)) continue;
        if (s[i][j] != s[ny][nx]) uf.unite(i*w+j, ny*w+nx); 
      }
    }
  }
  ll res = 0;
  rep(i,h) rep(j,w) if (s[i][j] == '#') mp[uf.find(i*w+j)]++;
  rep(i,h) rep(j,w) if (s[i][j] == '#') res += uf.size(i*w+j) - mp[uf.find(i*w+j)];
  cout << res << endl;
  return 0;
} 

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

using namespace std;

int main() {
	string s; cin >> s;
	int left=0,right=s.size()-1;
	int ans=0;
	while(left<right) {
		if(s[left]!=s[right]) {
			++ans;
			if(s[left]=='x') {
				++left;
			} else if(s[right]=='x') {
				--right;
			} else {
				cout << -1 << endl;
				return 0;
			}
		} else ++left,--right;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MAXN	305
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct edge {int l, cnt; };
vector <edge> limit[MAXN];
int dp[2][MAXN][MAXN];
void update(int &x, int y) {
	x = (x + y) % P;
}
void transition(int x, int y, int z, int tmp) {
	for (unsigned i = 0; i < limit[x].size(); i++) {
		int tnp = 1;
		if (y >= limit[x][i].l) tnp++;
		if (z >= limit[x][i].l) tnp++;
		if (tnp != limit[x][i].cnt) return;
	}
	update(dp[x & 1][y][z], tmp);
}
int main() {
	int n, m;
	read(n), read(m);
	for (int i = 1; i <= m; i++) {
		int x, y, z;
		read(x), read(y), read(z);
		limit[y].push_back((edge) {x, z});
	}
	dp[0][0][0] = 1;
	for (int i = 1, now = 0, nxt = 1; i <= n; i++, now ^= 1, nxt ^= 1) {
		memset(dp[nxt], 0, sizeof(dp[nxt]));
		for (int j = 0; j < i; j++)
		for (int k = 0; k < i; k++) {
			if (dp[now][j][k] == 0) continue;
			int tmp = dp[now][j][k];
			transition(i, j, k, tmp);
			transition(i, i - 1, k, tmp);
			transition(i, j, i - 1, tmp);
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
	for (int j = 0; j <= n; j++)
		update(ans, dp[n & 1][i][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	double N,T,A;
	double H[1010];
	double A_tono_sa[1010];
	int point = 0;

	double min = 1000000;

	cin >> N>>T>>A;

	for (int i = 0; i < N; ++i) {
		cin >> H[i];
		A_tono_sa[i] =A- (T - H[i] * 0.006);

		if (A_tono_sa[i] < 0) A_tono_sa[i] = A_tono_sa[i] * (-1);
	}

	for (int i = 0; i < N; ++i) {
		if (A_tono_sa[i] < min) {
			min = A_tono_sa[i];
			point = i+1;
		}
	}

	cout << point << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define _USE_MATH_DEFINES
using namespace std;
int main()
{
ll a,b;
cin>>a>>b;
if((a+b)%2==0)
{
cout<<(a+b)/2;
}
else
{
cout<<"IMPOSSIBLE";
}
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// --------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >> N >> M;
  vector<string> A(N),B(M);
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<M; i++) cin >> B[i];
  bool can = false;
  for(int i=0; i+M<=N; i++){
    for(int j=0; j+M<=N; j++){
      bool ok = true;
      for(int k=0; k<M; k++){
        for(int l=0; l<M; l++){
          if(A[i+k][j+l] != B[k][l]) ok = false;
        }
      }
      if(ok) can = true;
    }
  }
  cout << (can ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll Inf = 1e18;

ll n,W;
ll w[110];
ll v[110];

ll Dp[110][100100];

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

    for(ll i=0;i<n;i++) scanf("%I64d%I64d",w+i,v+i);

    for(ll V=1;V<100100;V++)    Dp[n][V] = Inf;

    for(ll i=n-1;i>=0;i--)
        for(ll V=0;V<100100;V++)
            Dp[i][V] = min( Dp[i+1][V] , V>=v[i] ? Dp[i+1][V-v[i]] + w[i] : Inf );

    for(ll V=100099;V>=0;V--)
        if(Dp[0][V]<=W)
            return cout<<V,0;

}


Measured memory_bytes: 80128
x, y = map(int, input().split())
res = 0
if x == 3:
    res += 100000
elif x == 2:
    res += 200000
elif x == 1:
    res += 300000

if y == 3:
    res += 100000
elif y == 2:
    res += 200000
elif y == 1:
    res += 300000

if x == y == 1:
    res += 400000
print(res)


Measured memory_bytes: 38384
n,k = a = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

count = Hash.new{|h,k| h[k] = 0}

n.times do |i|
  count[a[i]] +=1
end

count = count.sort_by {|k, v| v}

ans = 0

0.upto(count.length-k-1) do |i|
  ans += count[i][1]
end

puts ans


Measured memory_bytes: 40960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
大部分を再利用できそう
*/

ll n,a[200010],ans[200010];
V<ll> v[200010],lis(200010,1e18);

void f(ll p,ll par){
	auto lis_p = lower_bound(lis.begin(), lis.end(), a[p]);  // 操作を記録しておく
	ll before = *lis_p;  //
	*lis_p = a[p];
	ans[p] = lower_bound(lis.begin(), lis.end(), 1e18) - lis.begin();  // lisを記録
	for(auto q:v[p]){
		if(q!=par){
			f(q,p);
		}
	}
	*lis_p = before;  // 巻き戻す
}

int main(void){
	cin>>n;
	reg(i,1,n)cin>>a[i];
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	f(1,0);
	reg(i,1,n)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 30284
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

vector<long long> f(long long N){
    vector<long long> res;
    long long i;
    for(i=1;i*i<N;i++){
        if(i>1000000)cout<<i<<endl;
        if(N%i==0){
            res.push_back(i);
            res.push_back(N/i);
        }
    }
    if(i*i==N){
        res.push_back(i);
    }
    return res;
}

int g(long long p,long long N){
    while(N%p==0){
        N/=p;
    }
    if(N%p==1){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    long long N;
    cin>>N;

    auto v=f(N-1);
    auto w=f(N);
    long long ans=v.size()-1;
    //for(auto p:w){cout<<p<<" ";}cout<<endl;
    for(auto p:w){
        if(p!=1){
            ans+=g(p,N);
        }
    }
    cout<<ans<<endl;

    
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  ll n,d;
  cin >> n >> d;
  d = d*d;
  int cnt = 0;
  while(n--)  {
    ll x,y;cin >> x >> y;
    if(d >= x*x+y*y)cnt++;
  }
  cout << cnt << endl;
  

  return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a % 2== 0 || b % 2== 0 ) {
            System.out.println("No");
        }else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21712
let input = require('fs').readFileSync('/dev/stdin', 'utf8')
// let input = require('fs').readFileSync('./sample_c.txt', 'utf8')
.split(/\n| /)
.map(item => parseInt(item))
.slice(1,-1)

let max = input[0]
let stage = 0
input.slice(1).forEach( item => {
    if(item < max) {
        stage += max - item 
    } else {
        max = item
    }
} )

console.log(stage)

Measured memory_bytes: 59828
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = 1e9 + 7;
using namespace std;

int main()
{
    IOS
    int v[3] = {};
    for(int i= 0;i<3;i++)
    {
        cin >> v[i];
    }
    sort(v,v+3);
    cout << v[2] - v[0] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pii, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

struct LazySegTree {
    int siz;
    vector<ll> node, lazy, mpsum, idist;

    LazySegTree(int N) : siz(1) {
        while (siz < N)
            siz *= 2;
        node.resize(2 * siz - 1, 0);
        lazy.resize(2 * siz - 1, -1);
        idist.resize(2 * siz - 1, 1);

        mpsum.resize(2 * siz - 1, 0);
        for (int i = 1; i < 2 * siz - 1; ++i)
            mpsum[i] = (mpsum[i - 1] * 10 + 1) % MOD;

        for (int i = 0; i < N; ++i)
            node[i + siz - 1] = 1;
        for (int i = siz - 2; i >= 0; --i) {
            idist[i] = idist[2 * i + 1] * 2;
            node[i] = (node[2 * i + 1] + node[2 * i + 2] * getpow(idist[i] / 2)) % MOD;
        }
    }

    ll getpow(int k) {
        return getspow(k, k + 1);
    }

    ll getspow(int l, int r) {
        ll res = mpsum[r] - mpsum[l];
        if (res >= MOD)
            res -= MOD;
        if (res < 0)
            res += MOD;
        return res;
    }

    void eval(int k) {
        if (lazy[k] < 0)
            return;
        if (k < siz - 1) {
            lazy[2 * k + 1] = lazy[k];
            lazy[2 * k + 2] = lazy[k];
        }

        node[k] = getspow(0, idist[k]) * lazy[k] % MOD;
        lazy[k] = -1;
    }

    void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        eval(k);
        if (r <= a || b <= l)
            return;
        if (a <= l && r <= b) {
            lazy[k] = x;
            eval(k);
            return;
        }
        update(a, b, x, 2 * k + 1, l, (l + r) / 2);
        update(a, b, x, 2 * k + 2, (l + r) / 2, r);
        node[k] = (node[2 * k + 1] + node[2 * k + 2] * getpow(idist[k] / 2)) % MOD;
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        eval(k);
        if (r <= a || b <= l)
            return 0;
        if (a <= l && r <= b)
            return node[k];
        ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (vl + vr * getpow(idist[k] / 2)) % MOD;
    }
};

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

    int N, Q;
    cin >> N >> Q;
    LazySegTree seg(N);
    for (int i = 0; i < Q; ++i) {
        int L, R, D;
        cin >> L >> R >> D;
        L = N - L + 1, R = N - R + 1;
        swap(L, R);
        L--;
        seg.update(L, R, D);
        ll res = seg.query(0, N);
        if (res < 0)
            res += MOD;
        cout << res << '\n';
    }

    return 0;
}


Measured memory_bytes: 19608
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		doIt();

	}
	
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String s[] = str.split(",");
		int dis = Integer.parseInt(s[0]);
		int ang = Integer.parseInt(s[1]);
		double x = 0, y = 0;
		int angle = 90;

		while(dis != 0 || ang != 0){
			double rad = ((double)angle / 180) * Math.PI;
			x += dis * Math.cos(rad);
			y += dis * Math.sin(rad);
			angle -= ang;
			str = sc.next();
			s = str.split(",");
			dis = Integer.parseInt(s[0]);
			ang = Integer.parseInt(s[1]);
			
		}
		System.out.println((int)x);
		System.out.println((int)y);
		
	}

}

Measured memory_bytes: 11000
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	string s;
  	cin >> s;
  	int n = s.size();
	cout << s[0];
  	cout << n-2;
  	cout << s[n-1] << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 998244353;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += i;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<P> vec;
  rep(i,n){
    ll a, b;
    cin >> a >>b;
    vec.emplace_back(P(b,a));
  }
  sort(vec.begin(), vec.end());
  ll total=0;
  for(auto p:vec){
//    cout << p.first << ' ' << p.second << endl;
    total += p.second;
//    cout << total << endl;
    if (p.first < total){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

const int maxn=55,maxm=22;

long long dp[maxn][1<<maxm];
int n,m,msk[maxn];
vector <pair<int,int> > g[maxn];

bool dfs(int id,int x,int fa,int ed){
	if(x==ed) return true;
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i].first,ind=g[x][i].second;
		if(to==fa) continue;
		if(dfs(id,to,x,ed)){
			msk[ind]|=1<<id;
			return true;
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--; b--;
		g[a].push_back(make_pair(b,i));
		g[b].push_back(make_pair(a,i));
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--; b--;
		dfs(i,a,-1,b);
	}
	dp[0][0]=1;
	for(int i=0;i<n-1;i++){
		for(int mask=0;mask<(1<<m);mask++){
			dp[i+1][mask]+=dp[i][mask];
			dp[i+1][mask|msk[i]]+=dp[i][mask];
		}
	}
	printf("%lld\n",dp[n-1][(1<<m)-1]);
	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long n, long long k) {
    cout << fixed << setprecision(9);
    double ans = 0.0;
    rep(i, n) {
        int    point = i + 1;
        double cnt   = 0.0;
        while (point < k) {
            point *= 2;
            cnt++;
        }
        ans += (1 / (double)n) * pow(0.5, cnt);
    }
    cout << ans << endl;
}

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

    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    func(N, K);
    return 0;
}


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

const ll INF = pow(10, 9) + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll sum = 0;
  rep(i,n){
    for(int j = i + 1 ;j < n - 1;j++){
      int s = a[i] + a[j];
      int r = lower_bound(a.begin(),a.end(),s) - a.begin();
      sum += max(0,r-j-1);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,r;
    cin >> n >> r;
    if(n>=10){
        cout << r;
    }
    else{
        cout << r + (10-n)*100; 
    }

    return 0;
}

Measured memory_bytes: 3548
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        Arrays.sort(a);
        boolean[] cnt = new boolean[n];
        Arrays.fill(cnt,true);
        int[] exist = new int[1000003];
        int index = 1;
        for(int v : a){
            if(exist[v] != 0){
                cnt[index-1] = false;
                cnt[exist[v]-1] = false;
            }else{
                int max = (int)Math.sqrt(v);
                for(int i = 1; i <= max; i++){
                    if(v % i == 0){
                        if(exist[i] != 0){
                            cnt[index-1] = false;
                        }
                        if(exist[v/i] != 0){
                            cnt[index-1] = false;
                        }
                    }
                }
            }
            exist[v] = index;
            index++;
        }
        int ans = 0;
        for(int i = n-1; i >= 0; i--){
            if(cnt[i]){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 49152
def judge(x,y):
    global xx,yy,xy,axby
    if min(x,y) >= 0 and x+y <= xy:
        if x+y < xy or (x+y == xy and a*x+b*y < axby):
            xy = x+y
            axby = a*x+b*y
            xx,yy = x,y
    
while 1:
    a,b,d = map(int,raw_input().split())
    if a == 0: break
    xy = axby = 10**10
    for y in xrange(30001):
        if (d+b*y)%a == 0: judge((d+b*y)/a,y)
        if (b*y-d)%a == 0: judge((b*y-d)/a,y)
        if (d-b*y)%a == 0: judge((d-b*y)/a,y)
    print xx,yy

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
const int inf=1e9+7;

int main()
{	
    ll N,W;
    cin>>N>>W;
    ll wt[N],v[N];
    loop(i,0,N)
    cin>>wt[i]>>v[i];
    ll dp[N+1][W+1];
    loop(i,0,W+1)
     dp[0][i]=0;
     loop(i,0,N)
     {
     	loop(w,0,W+1)
     	{
     		if(w>=wt[i])
     		{
     			dp[i+1][w]=max(dp[i][w],dp[i][w-wt[i]]+v[i]);
			 }
			 else
			  dp[i+1][w]=dp[i][w];
		 }
	 }
	 cout<<dp[N][W];
    return 0;
}


Measured memory_bytes: 79104
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    int r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N;
    cin >> N;
    N++;
    vector<int> x(N);
    for (auto &i : x) cin >> i;

    sort(x.begin(), x.end());
    int ans = x[1] - x[0];
    for (int i = 2; i < N; i++) {
        ans = gcd(ans, x[i] - x[i - 1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer stk;
		String str="";
		int a_pos=0,b_pos=0,c_pos=0,range=0;

		try {
			str=bfr.readLine();
			if(str.equals("")) {
				System.exit(0);
			}
			else {
				stk=new StringTokenizer(str," ");
				a_pos=Integer.parseInt(stk.nextToken());
				b_pos=Integer.parseInt(stk.nextToken());
				c_pos=Integer.parseInt(stk.nextToken());
				range=Integer.parseInt(stk.nextToken());

				if(Math.abs(a_pos-b_pos)<=range && Math.abs(b_pos-c_pos)<=range) {
					System.out.println("Yes");
				}
				else if(Math.abs(c_pos-a_pos)<=range){
					System.out.println("Yes");
				}
				else {
					System.out.println("No");
				}

			}
		}catch(IOException e) {

		}
		catch(NumberFormatException ee) {
			System.exit(0);
		}

		catch(NullPointerException eee) {
			System.exit(0);
		}

	}
}

Measured memory_bytes: 21076
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt()
  var t , a = sc.nextInt()
  var h = Array.fill(n)(sc.nextDouble())
  for (i <- 0 until h.length){
    h(i) = (a - (t - h(i) * 0.006)).abs
  }
  println(h.indexOf(h.min) + 1)
}


Measured memory_bytes: 60148
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int a,b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

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

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = n /(a + b) * a + min(a,n%(a + b));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = (int)1e3 +10;

int main()
{
    int n;
    cin>>n;
   // getchar();
    int arr[60];
    arr[0] = 0;
    //int b[5][2];
    int pos = 0;
    for(int i = 1; i <= n; i++)
    {
        cin>>arr[i];
        if(arr[i] != i)
        {
//            b[pos++][0] = arr[i];
//            b[pos][1] = i;
            pos++;
        }
    }
    if(pos == 0 || pos == 2) cout<<"YES"<<endl;
//    else if(pos == 2)
//    {
//        if(b[0][0] == b[1][1] && b[0][1] == b[1][0])
//            cout<<"YES"<<endl;
//        else cout<<"NO"<<endl;
//    }
    else cout<<"NO"<<endl;

    return 0;
}





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

int main() {
    long long int N, K;
    cin >> N >> K;

    long long int ans = 0;

    for (long long int i = K; i < N + 2; ++i) {
        long long int min = (i - 1) * i / 2;
        long long int max = (2 * N - i + 1) * i / 2;
        long long int diff = max - min + 1;

        ans += diff;
        ans %= 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll A, B;

ll cal(ll digit){
    cerr <<"-----------------------------" << endl;

    ll base = pow(2, digit);
    cerr << "digit: " << digit << ", base:" << base << endl;

    ll freq = base * 2;

    ll m = A/freq;
    ll from = m * freq;

    ll M = B/freq + 1;
    ll till = M * freq - 1;

    ll num = (till - from) + 1;
    num /= 2;
    cerr <<"basicly: from , A, B , till" << endl;
    cerr << from << " " << A <<"  " << B << " " << till << endl;
    cerr << "max num:" << num << endl;

    if((A-from) > base){
        num -= (A-from)-base;
        cerr << "minus former" << " " << (A-from)-base << endl;
    }
    if((till-B) < base){
        num -= (till-B);
        cerr <<"mins some after" << " " << (till-B) << endl;
    }else {
        num-= base;
        cerr <<"mins all after" << " " << base << endl;
    }

    if((num%2) == 1 ){
        cerr << "--->" << digit << endl;
         return pow(2, digit);
     }

    else return 0;
}


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

    cin >> A >> B ;

    ll ans = 0 ;
    rep(i, 41){
        ans += cal(i);
    }
    cout << ans << endl;

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using Int = int64_t;

int main() {
   for(;;) {
      Int n;
      std::cin >> n;
      if( n == 0 ) break;
      std::vector<Int> xs(n);
      for(Int i = 0; i < n; ++i) {
         std::cin >> xs[i];
      }
      std::sort(xs.begin(), xs.end());
      Int total = 0;
      for(Int i = 1; i < (Int)xs.size()-1; ++i) {
         total += xs[i];
      }
      Int res = total / (n-2);
      std::cout << res << std::endl;
   }
}



Measured memory_bytes: 3124
N,Q = map(int,input().split())

s = input()

pre = [0]

for i,c in enumerate(s):
  last = pre[len(pre) -1 ]
  if i > 0 and c == 'C' and s[i-1] == 'A':
    pre.append(last+1)
  else:
    pre.append(last)
    
for _ in range(Q):
  l,r = map(int,input().split())
  ans = pre[r] - pre[l-1] + (0 if pre[l-1] == pre[l] else -1)
  print(ans)


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{ 
    ll n,t,a,ans;
    cin >> n >> t >> a;
    double tha,diff,min=M;
    vll h(n);
    rep(i,n){
        cin >> h[i];
        tha = t - h[i]*0.006;
        diff = abs(a-tha);
        if(min >= diff){
            ans = i;
            min = diff;
        }
    }
    cout << ans+1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
s = list(input())
ans = 0
temp_ans = 0
for i in s:
    if i == "A" or i == "C" or i == "G" or i == "T":
        temp_ans += 1
    else:
        temp_ans = 0
    ans = max(temp_ans,ans)
    #print(temp_ans)
print(ans)
#print(s)

Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner s = new Scanner(System.in)) {
            String n = s.next();
            System.out.println(unit(n));
        }
    }
    private static String unit(String n) {
        switch (n.charAt(n.length() - 1)) {
            case '3':
                return "bon";
            case '0':
            case '1':
            case '6':
            case '8':
                return "pon";
            default:
                return "hon";
        }
    }
}

Measured memory_bytes: 35696
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200200;
int a[N];
int n, k;
set<int> setik;
bool canStay = false;
bool isLeftMin[N], isRightMax[N];
bool stay[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < k; i++)
		setik.insert(a[i]);
	for (int i = 0; i + k <= n; i++) {
		isLeftMin[i] = a[i] == *setik.begin();
		isRightMax[i + k - 1] = a[i + k - 1] == *setik.rbegin();
		if (i + k == n) break;
		setik.erase(a[i]);
		setik.insert(a[i + k]);
	}
	int cnt = 0;
	for (int i = 1; i < k; i++)
		cnt += (int)(a[i - 1] < a[i]);
	for (int i = 0; i + k <= n; i++) {
		stay[i] = cnt == k - 1;
		canStay |= stay[i];
		if (i + k == n) break;
		cnt -= (int)(a[i] < a[i + 1]);
		cnt += (int)(a[i + k - 1] < a[i + k]);
	}
	int ans = (int)canStay;
	for (int i = 0; i + k <= n; i++) {
		if (stay[i]) continue;
		if (i > 0 && isLeftMin[i - 1] && isRightMax[i + k - 1]) continue;
		ans++;
	}
	printf("%d\n", ans);

	return 0;
}


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

int main() {
  int n, v;
  cin >> n;
  int V[n];
  for(int i = 0; i < n; i++) {
    cin >> V[i];
  }
  sort(V, V + n);

  float mean = (float)V[0];
  for(int i = 1; i < n; i++) {
    float next = (float)V[i];
    mean = (mean + next) / 2.0;
  }

  cout << mean << endl;
}


Measured memory_bytes: 256
/* C Tree Walk */

#include<stdio.h>

int T[26][4];/*T[n][0]=P, T[n][1]=L(left child), T[n][2]=R(right child), T[n][3]=id*/
int n;

void Preorder(int u[]);
void Inorder(int u[]);
void Postorder(int u[]);

int main(){
  int i, j;
  int id, l, r;
  int rootid;


  scanf("%d",&n); 

  /* initialize T[n][3]*/
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      T[i][j]=-1;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id][3]=id;
    T[id][1]=l;
    T[id][2]=r;
    T[l][0]=id;
    T[r][0]=id;
  }
  
  for(i=0;i<n;i++){
    if(T[i][0]==-1){
      rootid=i;
      break;
    }
  }

  printf("Preorder\n");
  Preorder(&T[rootid][0]);
  printf("\n");
 
  printf("Inorder\n");
  Inorder(&T[rootid][0]);
  printf("\n");

  printf("Postorder\n");
  Postorder(&T[rootid][0]);
  printf("\n");
  return 0;
}

void Preorder(int u[4]){
  printf(" %d",u[3]);
  if(T[u[3]][1]!=-1)Preorder(T[u[1]]);
  if(T[u[3]][2]!=-1)Preorder(T[u[2]]);
}

void Inorder(int u[4]){
  if(T[u[3]][1]!=-1)Inorder(T[u[1]]);
  printf(" %d",u[3]);
  if(T[u[3]][2]!=-1)Inorder(T[u[2]]);
}

void Postorder(int u[4]){
  if(T[u[3]][1]!=-1)Postorder(T[u[1]]);
  if(T[u[3]][2]!=-1)Postorder(T[u[2]]);
  printf(" %d",u[3]);
}


  
  
  

Measured memory_bytes: 0
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int k, a, b;
  cin >> k;
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include<string.h>
using namespace std;


int main() {

	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);
int GCD(int , int);


int main(){
    int n;
    cin >> n;
    bool flag = false;
    for(int i=1;i<=9;i++){
        if(n/i <=9 && n/i >=1 && n%i == 0) flag =true;
    }
    if(flag) cout<<"Yes" << endl;
    else cout << "No" << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法
int gcd(int a, int b){
    while(1){
        int remain = a % b;
        if(remain == 0) return b;
        else{
            a = b;
            b = remain;
        }
    }
}

int GCD(int a, int b) {
  return b ? GCD(b, a%b) : a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i<n;i++)
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {cin >> a.at(i);}
  sort(a.begin(), a.end());
  cout << a.at(N - 1) - a.at(0) << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i,0,n) cin >> v[i];
	sort(all(v));
	int l = 0, r = n-1;
	int ans = n;
	while(l <= r){
		int m = l + (r-l)/2;
		bool dp[k + 1] = {};
		dp[0] = 1;
		rep(i,0,n){
			if(i == m)continue;
			for(int j = k - v[i];j >= 0; --j){
				dp[j+v[i]] |= dp[j];
			}
		}
		bool val = false;
		rep(i,max(k-v[m], 0), k){
			val |= dp[i];
		}
		if(val){
			ans = m;
			r = m - 1;
		}
		else{
			l = m + 1;	
		}
	}
	cout << ans << '\n';
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define RSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))
#define PREC(n) setprecision(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    ll i,j,k,n,x,y,z;
    vll a,b;

	cin>>n;

    SIZE(a,n);
    SIZE(b,n);
    j=1;
    rep(i,n){
        cin>>a[i];
        j*=(i+1);
    }
    rep(i,n){
        cin>>b[i];
    }
    x=0;
    y=0;
    rep(i,n){
        k=n-i;
        x+=(j/k)*(a[i]-1);
        y+=(j/k)*(b[i]-1);
        j/=k;
        rep(z,n){
            if(a[i]<a[z])a[z]--;
            if(b[i]<b[z])b[z]--;
        }
    }
    cout<<abs(x-y)<<endl;

	return 0;
}


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

#include <string>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <math.h>

const double PI = 3.14;


int main()
{
	unsigned a1, a2;
	cin >> a1 >> a2;

	cout << ( ((a1+1)*a1) / 2 - a1 ) + ( ((a2+1)*a2) / 2 - a2 ) << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> os;

int k, x;
map <string, int> t;
int main(){
  int n; cin >> n;
  vector <string> v(n);
  rep(i, 0, n - 1) cin >> v[i], sort(v[i].begin(), v[i].end()), t[v[i]]++;

  ll ans = 0;
  for(map <string, int> :: iterator it = t.begin(); it != t.end(); it++)
    ans += 1ll * (it -> second) * (it -> second - 1) / 2;
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18176
<?php
  
  fscanf(STDIN,"%d",$n);
$a_li = explode(" ",trim(fgets(STDIN)));
$min = 1000000;
$count=0;
foreach($a_li as $a){
  while($a%2==0){
    $a = $a/2;
    $count++;
  }
  $min = min($count,$min);
  $count=0;
}

echo $min."\n";
    

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

namespace TYC
{
	void work()
	{
		int K, n;
		scanf("%d", &K);
		if (K == 1)
			return void(puts("1\n1"));
		printf("%d\n", n = (K + 3) / 4 * 2);
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
				if (i & 1)
					printf("%d ", (i + j) % n + 1);
				else
				{
					int c = (i + j) % n + n + 1;
					printf("%d ", c > K ? c - n : c);
				}
			puts("");
		}
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void)
{
    int N,K,P,i,n,W;
	scanf("%d",&N);
	for(i=0;i<N;i++){
	    scanf("%d %d",&K,&P);
		W=K;
		for(n=0;n<K;n++){
			if(W<=P){
			    break;
			}
			W=W-P;
		}
		printf("%d\n",W);
	}
	return 0;
}

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

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int time1 = 60*h1 + m1;
    int time2 = 60*h2 + m2;

    int time = time2 - time1;
    


    cout << time - k << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    if(a>=13){
        cout << b << endl;
    }else if(5 >= a){
        cout << 0 << endl;
    }else{
        cout << b/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int [] nums = new int[5];
        for(int i = 0 ; i< 5;i++){
        
        nums[i] = scanner.nextInt();
               }
        
         for(int i = 0 ; i< 5;i++){
         if(nums[i] == 0){
             System.out.println(i+1);
         }
         
         
         
         }
        
        
        
    }
    
}


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

int main(){
  int n,k,i,a[200010],sum;
  int lh,rh=0,mid;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){scanf("%d",&a[i]);rh=max(rh,a[i]);}
  
  lh=0;
  while(rh!=lh+1){
    mid=(rh+lh)/2;
    sum=0;
    for(i=0;i<n;i++){sum += (a[i]-1)/mid;}
    if(sum<=k){
      rh = mid;
    }else{
      lh = mid;
    }
//    printf("%d %d\n",lh,rh);
  }
  printf("%d\n",rh);
  return 0;
}

Measured memory_bytes: 4396