akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=20005,INF=1<<20;

int par[MAX],size[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)){
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        map<int,int> MX,MY;
        vector<int> X1(N),Y1(N),X2(N),Y2(N);
        
        for(int i=0;i<N;i++){
            int x1,y1,x2,y2;cin>>x1>>y2>>x2>>y1;
            MX[x1]=1;
            MX[x2]=1;
            MY[y1]=1;
            MY[y2]=1;
            
            X1[i]=x1;
            Y1[i]=y1;
            X2[i]=x2;
            Y2[i]=y2;
        }
        int idx=1,idy=1;
        for(auto it=MX.begin();it!=MX.end();it++,idx++){
            MX[(*it).first]=idx;
        }
        for(auto it=MY.begin();it!=MY.end();it++,idy++){
            MY[(*it).first]=idy;
        }
        
        for(int i=0;i<N;i++){
            X1[i]=MX[X1[i]];
            Y1[i]=MY[Y1[i]];
            X2[i]=MX[X2[i]];
            Y2[i]=MY[Y2[i]];
        }
        
        init(idx*idy);
        
        set<pair<int,int>> out;
        
        for(int i=0;i<N;i++){
            for(int j=Y1[i];j<Y2[i];j++){
                out.insert({X1[i]-1+j*idx,X1[i]+j*idx});
                out.insert({X2[i]-1+j*idx,X2[i]+j*idx});
            }
            
            for(int j=X1[i];j<X2[i];j++){
                out.insert({j+(Y1[i]-1)*idx,j+Y1[i]*idx});
                out.insert({j+(Y2[i]-1)*idx,j+Y2[i]*idx});
            }
        }
        
        for(int j=0;j<idy;j++){
            for(int i=0;i+1<idx;i++){
                if(out.count({i+j*idx,i+1+j*idx})==0){
                    unite(i+j*idx,i+1+j*idx);
                }
            }
        }
        
        for(int i=0;i<idx;i++){
            for(int j=0;j+1<idy;j++){
                if(out.count({i+j*idx,i+(j+1)*idx})==0){
                    unite(i+j*idx,i+(j+1)*idx);
                }
            }
        }
        set<int> SE;
        
        for(int i=0;i<idx*idy;i++){
            SE.insert(root(i));
            //cout<<i<<" "<<root(i)<<endl;
        }
        
        cout<<SE.size()<<endl;
    }
}





Measured memory_bytes: 3868
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if ((a + b) % 2 == 0){
		printf("%d\n", (a + b) / 2);
	}
	else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}

Measured memory_bytes: 128
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q, l[ohara], r[ohara];
P p[ohara];
ll dat[ohara], le = -LINF, ri = LINF;

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

  cin >> n;
  rep(i, n) { cin >> p[i].fi >> p[i].se; }
  sort(p, p + n);
  rep(i, n) l[i] = p[i].fi, r[i] = p[i].se;

  rrrep(i, n - 1, 0) {
    le = max(le, l[i]);
    ri = min(ri, r[i]);
    // cout << le << " " << ri << "\n";
    dat[i] = max(0LL, ri - le + 1);
  }
  le = -LINF, ri = LINF;
  rep(i, n - 1) {
    le = max(le, l[i]);
    ri = min(ri, r[i]);
    ans = max(dat[i + 1] + max(0LL, ri - le + 1), ans);
  }
  ll ri = LINF, le = -LINF;
  rep(i, n) {
    ri = min(ri, r[i]);
    le = max(le, l[i]);
  }
  rep(i, n) { tmp = max(r[i] - l[i] + 1, tmp); }
  ans = max(ans, max(0LL, ri - le + 1) + tmp);
  // rep(i, n) Cout(dat[i]);
  Cout(ans);
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int W[N];
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
        sum += W[i];
    }
    int ans = INT_MAX;
    int suml = 0;
    for (int i = 0; i < N - 1; i++)
    {
        sum -= W[i];
        suml += W[i];
        ans = min(ans, abs(sum - suml));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int L, R;
  cin >> L >> R;
  R = min(R, L + 2018);
  int ans = 2020;
  FORS(i, L, R) {
    FORS(j, i + 1, R) { ans = min(ans, ((i % 2019) * (j % 2019)) % 2019); }
  }
  print(ans);
  // print();
}

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

int	main()
{
	int64_t	A, B, N;
	cin >> A >> B >> N;
	if (N > B - 1)
		N = B - 1;
	cout << (A / B) * N + ((A % B) * N) / B << endl;
}


Measured memory_bytes: 3592
mod=10**9+7


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


n,m=map(int,input().split())


if m==1:
    print(1)
    exit()


x=factorization(m)

ans=1

for i in x:
    ans*=cmb(n+i[1]-1,i[1])
    ans%=mod


print(ans)


Measured memory_bytes: 68232
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
#define REP(m,n) for(int i=m;i<n;++i)
#define REPj(m,n) for(int j=m;j<n;++j)
#define INF 10000000000000000
#define ll long long
#define mp make_pair

int main() {
	ll a, b, c, d, n, e, f, ans;
	cin >> a >> b >> c >> d >> n;
	e = min(min(a * 8, b * 4), min(c * 2, d));
	f = min(min(a * 4, b * 2), c);
	if (n % 2 == 1) {
		ans = n / 2 * e + f;
		cout << ans << endl;
	}
	else {
		ans = n / 2 * e;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#include<iostream>
#include<cstring>
#include<cstdio>
//#include<time.h>
//#include<complex>
//#include<set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;

int n;
#define maxn 200011
int a[maxn];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	
	int ans=0; double ff=a[n]/2.0,Min=a[n]+3;
	for (int i=1;i<n;i++) if (fabs(a[i]-ff)<Min) {Min=fabs(a[i]-ff); ans=a[i];}
	printf("%d %d\n",a[n],ans);
	return 0;
}

Measured memory_bytes: 512
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

amari=0
goukei=0
for i in range(N):
    if B[i] > A[i]:
        goukei += A[i]
        
        if (B[i]-A[i]) >=A[i+1]:
            goukei += A[i+1]
            A[i+1] = 0
        else:
            goukei += (B[i]-A[i])
            A[i+1] -= (B[i]-A[i])
    else:
        goukei += B[i]
print(goukei)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<ll> vSize;

    UnionFind(ll N) : par(N), vSize(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++)
        {
            par[i] = i;
            vSize[i] = 1;
        }
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        vSize[ry] += vSize[rx];
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x){    // データxが属する木の頂点数を得る
        ll rx = root(x);
        return vSize[rx];
    }
};

int main()
{
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(M), B(M), C(K), D(K);
    vector<ll> G[N];
    REP(i, M)
    {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    REP(i, K)
    {
        cin >> C[i] >> D[i];
        C[i]--;
        D[i]--;
    }

    UnionFind fr(N);
    REP(i, M)
    {
        fr.unite(A[i], B[i]);
    }
    vector<ll> bl[N];
    REP(i, K)
    {
        if (fr.same(C[i], D[i]))
        {
            bl[C[i]].push_back(D[i]);
            bl[D[i]].push_back(C[i]);
        }
    }
    REP(i, N)
    {
        ll ans;
        ans = fr.size(i) - G[i].size() - 1;
        ans -= bl[i].size();
        cout << ans << " ";
    }
    cout << endl;
}


Measured memory_bytes: 17652
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

class State{
public:
  int cost,x,y;

  State(int _cost,int _x,int _y){
    cost = _cost;
    x = _x;
    y = _y;
  }
};

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

int main(void){
  int sx,sy;

  while(cin>>sx>>sy && (sx||sy)){
    int n;
    cin>>n;

    bool t[10][10][10];
    memset(t,0,sizeof(t));
    rep(i,n){
      int x,y;
      cin>>x>>y;
      REP(j,-1,2) REP(k,-1,2) {
        int nx = x + j;
        int ny = y + k;
        if(nx>=0 && nx<10 && ny>=0 && ny<10) t[i][ny][nx] = true;
      }
    }

    queue<State> open;
    open.push(State(-1,sx,sy));
    bool ans = false;

    if(n == 0){
      cout<<"NA\n";
      continue;
    }

    while(!open.empty()){
      State st = open.front(); open.pop();

      if(st.cost == n-1){
        ans = true;
        break;
      }

      rep(i,12){
        int nx = st.x + dx[i];
        int ny = st.y + dy[i];
        int nc = st.cost + 1;

        if(nx>=0 && nx<10 && ny>=0 && ny<10 && t[nc][ny][nx]){
          open.push(State(nc,nx,ny));
          t[nc][ny][nx] = false;
        }
      }
    }
    cout<<(ans?"OK":"NA")<<endl;
  }

  return 0;
}

Measured memory_bytes: 1188
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto x = readln.split.to!(long[]);

    long ans = infl;

    foreach (p ; 0 .. 100 + 1) {
        long t;
        foreach (i ; 0 .. N) {
            t += (x[i] - p)^^2;
        }
        chmin(ans, t);
    }

    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  int n=s.size();

  string t;
  for(int i=0;i<n;i++){
    if(s[i]=='x') continue;
    t.push_back(s[i]);
  }
  int tn=t.size();
  string rt=t;
  reverse(rt.begin(),rt.end());
  for(int i=0;i<tn;i++){
    if(t[i]!=rt[i]){
      cout<<-1<<endl;
      return 0;
    }
  }

  int l=0,r=n-1;
  int ans=0;
  while(l<=r){
    if(s[l]==s[r]){
      l++;
      r--;
    }else if(s[l]=='x'){
      ans++;
      l++;
    }else if(s[r]=='x'){
      ans++;
      r--;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;


#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B) {
  int ans;
  if (A==B) {
    ans = A+B;
  } else {
    ans = 2*max(A,B) - 1;
  }
  cout << ans << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
c1, c2 = 0, 0
for i in range(X, N):
    if i in A:
        c1 += 1
for i in range(1, X+1):
    if i in A:
        c2 += 1
print(min(c1, c2))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
	int n;
	int a[100];
	double total = 0;
	double ans;

	cin >> n;

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

	//aの逆数の和
	for (int i = 0; i < n; i++)
	{
		total += 1.0 / a[i];
	}

	ans = 1.0 / total;
	
	cout << ans << endl;

	return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int> a, pair<int,int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (b - a >= 2018) {
		cout << 0 << endl;
		return 0;
	}
	a %= 2019;
	b %= 2019;
	if (b < a) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 2018;
	for (int i = a; i <= b; i++) {
		for (int j = i + 1; j <= b; j++) {
			int tmp = i * j;
			tmp %= 2019;
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// https://atcoder.jp/contests/dp/tasks/dp_l

ll dp[3500][3500];
ll a[3500];
bool flg[3500][3500];

ll calc(ll l, ll r) {
  if (flg[l][r]) return dp[l][r];

  if (r==l) dp[l][r] = a[l];
  else dp[l][r] = max(a[l] - calc(l+1, r), a[r] - calc(l, r-1));

  flg[l][r] = true;
  return dp[l][r];
}

int main() {
  int N; cin >> N;
  REP(i, N) cin >> a[i+1];

  cout << calc(1, N) << "\n";

  return 0;
}


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

int main(){
  int a[100003] = {0};
  for(int i=2;i<=316;i++){
    int j = 2;
    while(j * i <= 100003){
      a[(j * i)-1] = 1;
      j++;
    }
  }
  int x;
  cin >> x;
  while(1){
    if(a[x-1] == 0){
      cout << x << endl;
      break;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,k,temp;
  cin>>a>>b>>c>>k;
  if(k<=a)
    cout<<k;
  else if(k>a && k<=(a+b))
    cout<<a;
  else
  {
    temp=k-(a+b);
    cout<<(a-temp);
  }
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define maxn ((int)1e5+10)
using namespace std;
int n,k,ans=maxn;
vector<int> v;
int a[maxn];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
		a[x]=i;
	}
	for(int i=1;i<=n;i++)
	{
		int tmp=0,strong=k-1,left=a[i],right=n-a[i]-1;
		tmp+=left/strong;
		if(left%strong)
			++tmp;
		tmp+=right/strong;
		if(right%strong)
			++tmp;
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1276
N,M=map(int,input().split())
A=list(map(lambda x:int(x)*(-1),input().split()))

from heapq import heappop,heappush,heapify

heapify(A)
for _ in range(M):
    a=heappop(A)*(-1)
    a//=2
    heappush(A,a*(-1))

print(sum(A)*(-1))

Measured memory_bytes: 72216
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include<bits/stdc++.h>
using namespace std;

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 1e6+10;
int a[mxn];

int32_t main(){
	NINJA;

	int n; cin >> n;

	for(int i=1;i*i<=n;i++){
		for(int j=1;j*j<=n;j++){
			for(int k=1;k*k<=n;k++){
				int ans = ((i+j)*(i+j) + (j+k)*(j+k) + (k+i)*(k+i));
				ans /= 2;
				a[ans]++;
				// if(i==j && j==k && k==i){
				// 	a[ans] = 1;
				// }else{
				// 	a[ans] = 3;
				// }
			}
		}
	}

	for(int i=1;i<=n;i++) cout << a[i] << endl;
	
	return 0;
}

Measured memory_bytes: 4104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    ll res = 1;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        ll g = __gcd(res, a);
        res = a / g * res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll res = 0;
    res += min(a,k);
    k = max(0LL, k - a);
    k = max(0LL, k - b);
    res -= min(c, k);
    cout << res << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int INF = 2000000000;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int main(){
	int A, B, C, D; cin >> A >> B >> C >> D;
	ll dp[C+1][D+1];
	for(int i=A; i<=C; i++){
		for(int j=B; j<=D; j++){
			if(i==A&&j==B){
				dp[i][j] = 1;
				continue;
			}
			if(i==A){
				dp[i][j] = dp[i][j-1]*i%mod;
				continue;
			}
			if(j==B){
				dp[i][j] = dp[i-1][j]*j%mod;
				continue;
			}
			dp[i][j] = (dp[i-1][j]*j + dp[i][j-1]*i) % mod;
			dp[i][j] = (dp[i][j] + mod - ((i-1)*(j-1)%mod)*dp[i-1][j-1]%mod) % mod;
		}
	}
	cout << dp[C][D] << endl;
	return 0;
}


Measured memory_bytes: 73924
import sys
 
n = int(sys.stdin.readline())
s = list(sys.stdin.readline())

it = s[0]
w = 0
e = s[1:].count('E')

m = e
j = 0

for i in range(1, len(s)):
	if it == 'W':
		w = w + 1

	it = s[i]

	if it == 'E':
		e = e - 1

	m2 = w + e
	if m2 < m:
		m = m2
		j = i
print(m)


Measured memory_bytes: 8012
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

set<int> x;
set<int> y;
int main() {
	cin >> A >> B >> C >> D >> E >> F;
	for (int i = 0; A * i * 100 <= F; i++) {
		for (int j = 0; (A * i + B * j) * 100 <= F; j++) {
			x.insert(A * i + B * j);
		}
	}
	for (int i = 0; C * i <= F; i++) {
		for (int j = 0; C * i + D * j <= F; j++) {
			y.insert(C * i + D * j);
		}
	}
	double max_con = 0;
	Pa ans = Pa(0, 0);
	for (auto i = x.begin(); i != x.end(); i++) {
		for (auto j = y.begin(); j != y.end(); j++) {
			double con = 1. * (*j) / ((*i) * 100 + *j);
			if (con > 1. * E / (E + 100) || ((*i) * 100 + *j) > F) continue;
			if (max_con <= con) {
				max_con = con;
				ans = Pa((*i) * 100 + *j, *j);
			}
		}
	}
	cout << ans.first << " " << ans.second;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 二つの値の最大値を求める関数
Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}
Int Max(const vector<Int>& vec) {
    Int ret = vec[0];
    for (Int i = 1; i < (Int)vec.size(); ++i) {
        ret = Max(vec[i], ret);
    }
    return ret;
}

int main(void) {
    Int n;
    cin >> n;
    vector<Int> a1(n);
    vector<Int> a2(n);
    vector<Int> a1Sum(n);
    vector<Int> a2Sum(n);
    for (Int i = 0; i < n; ++i) {
        cin >> a1[i];
    }
    for (Int i = 0; i < n; ++i) {
        cin >> a2[i];
    }
    a1Sum[0] = a1[0];
    a2Sum[0] = a2[n - 1];
    for (Int i = 1; i < n; ++i) {
        a1Sum[i] = a1Sum[i - 1] + a1[i];
        a2Sum[i] = a2Sum[i - 1] + a2[n - 1 - i];
    }
    vector<Int> cost(n);
    for (Int i = 0; i < n; ++i) {
        cost[i] = a1Sum[i] + a2Sum[n - 1 - i];
    }
    Int result = Max(cost);
    cout << result << endl;
    return 0;
}



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

int main(){
    int N; cin>>N;
    vector<double> v(N);
    priority_queue< double, vector<double>, greater<double>> q;
    for(int i = 0; i < N ; i++){
        cin >> v[i];
        q.push(v[i]);
    }
    double res = 0;
    while(q.size() != 1){
        double x,y;
        x = q.top();q.pop();
        y = q.top();q.pop();
        res = (x+y)/2;
        q.push(res);
    }

    printf("%.15f\n",res);
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,k;
    cin >> n >> k;
    vint v(n);
    REP(i,n) v[i]=0;
    REP(i,k){
        int d;
        cin >> d;
        REP(j,d){
            int x;
            cin >> x;
            v[x-1]++;
        }  
    }
    int ans=0;
    REP(i,n){
        if(v[i]==0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

//iをlからrまで+1インクリメントでfor
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
// iを0からnまでfor
#define REP(i,n) FOR(i,0,n)

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

    REP(i,n){
        int x;
        cin >> x;
        if ( x != i+1 ) {
            count++;
        }
    }

    if (count <= 2) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){    
    ll N,K;
    cin>>N>>K;
    ll ans=0;
    for(ll i=K;i<=N;i++){
        ans+=(N*2-i+1)*i/2-(i-1)*i/2+1;
        ans%=MOD;
    }
    ans++;
    ans%=MOD;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
const int mod = 1e9+7;
const int limit=50;
int N, M;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
  visited[v] = true;
  for(int v2 = 0; v2 < N; v2++) {
    if(graph[v][v2] == false) continue;
    if(visited[v2]) continue;
    dfs(v2);
  }
}

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> a[i] >> b[i]; a[i]--, b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;
  for(int i = 0; i < M; i++) {
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
    bool bridge = false;
    for(int j = 0; j < N; j++) visited[j] = false;

    dfs(0);

    for(int j = 0; j < N; j++) {
      if(visited[j] == false) bridge = true;
    }
    if(bridge) ans++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math

A, B = map(int, input().split())

A_min = math.ceil(A * 12.5)
A_max = math.ceil((A + 1) * 12.5) - 1

B_min = math.ceil(B * 10)
B_max = math.ceil((B + 1) * 10) - 1
# print(A_min, A_max, B_min, B_max)
candidate = max(A_min, B_min)
if candidate < min(A_max, B_max):
    print(candidate)
else:
    print('-1')


Measured memory_bytes: 3188
def sol(k):

    def gen(d, cur, s):
        if d == k:
            yield s
            return
        for i in range(0, cur+1):
            yield from gen(d+1, max(cur, i+1), s+chr(97+i))

    return gen(0, 0, '')

def main():
    k = int(input())
    for x in sol(k):
        print(x)

if __name__ == '__main__':
    main()



Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

map<int,int> mp;
const int MAX_N=200001;
const int mod=1000000007;
ll fact[MAX_N+1];
ll inv[MAX_N+1],finv[MAX_N+1];
int inv_init(ll n,ll p){
    inv[1]=1;
    FOR(i,2,n+1) inv[i]=p-(p/i)*inv[p%i]%p;
    fact[0]=finv[0]=1;
    FOR(i,1,n+1){
        fact[i]=fact[i-1]*i%p;
        finv[i]=finv[i-1]*inv[i]%p;
    }
    return 0;
}
ll comb_mod(ll n,ll k,ll p){
    if(k<0||n<k) return 0;
    return finv[k]*finv[n-k]%p*fact[n]%p;
}
int main(){
    int n,m;
    cin>>n>>m;
    int tm=sqrt(m)+1;
    for(int i=2;i<=tm;++i){
        while(m%i==0){
            ++mp[i];
            m/=i;
        }
    }
    if(m!=1)++mp[m];
    inv_init(MAX_N,mod);
    ll ans=1;
    for(auto it:mp){
        ans*=comb_mod(it.second+n-1,it.second,mod);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
   int n,k;
   cin >> n >> k;
   vector<double> p(n);
   vector<long double> p_sum(n);
   rep(i,n){
      cin >> p.at(i);
   }
   p_sum.at(0)=(p.at(0)+1)/2.0;
   for(int i=1;i<n;i++){
      p_sum.at(i)=p_sum.at(i-1)+(p.at(i)+1)/2.0;
   }
   long double ans=p_sum.at(k-1);
   rep(i,n-k){
      long double sum=p_sum.at(i+k)-p_sum.at(i);
      ans=max(ans,sum);
   }
   cout <<fixed << setprecision(8)<< ans << endl;
}
    

Measured memory_bytes: 7932
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

template<typename T>
T power(T x, long long n, const T &m){
    if(n == 0) return 1;
    if(n == 1) return x;
    T tmp = power(x, n/2, m);
    if(n%2 == 0) return tmp * tmp % m;
    else return tmp * tmp % m * x % m;
}

template<typename T>
T inverse(T x, T m){
    return power(x, m-2, m);
}

struct Combination{
private:
    int N;
    long long M;
    vector<long long> f, i;
public:
    void init(int n, long long m){
        N = n; M = m;
        f.resize(N+1); f[0] = 1;
        i.resize(N+1); i[0] = 1;
        for(long long j=1; j<=N; j++){
            f[j] = f[j-1]*j%M;
            i[j] = inverse(f[j], M);
        }
    }
    long long fact(int n){
        return f[n];
    }
    long long C(int n, int r){
        return f[n] * i[r] % M * i[n-r] % M;
    }
};

int N;
ll C[200000];
Combination comb;
ll ans = 0;
signed main(){
    cin >> N;
    rep(i, N) cin >> C[i];
    sort(C, C+N);
    comb.init(N, MOD);

    for(ll i=0; i<N-1; i++){
        ll k = N-i-1;
        ll tmp = 0;
        /*for(ll j=0; j<=k; j++){
            tmp += (j+1)*comb.C(k, j);
            tmp %= MOD;
            //cout << (j+1)*comb.C(k, j) << endl;
        }*/
        //https://www.wolframalpha.com/input/?i=%5Csum_%7Bj%3D0%7D%5E%7Bk%7D+%28j%2B1%29*C%28k%2C+j%29&lang=ja
        tmp = power(2LL, k-1, MOD)*(k+2)%MOD;
        tmp *= power(2LL, k+1, MOD)*power(4LL, i, MOD)%MOD*C[i]%MOD;
        ans += tmp;
        ans %= MOD;
    }
    for(ll i=N-1; i<N; i++){
        ll k = N-i-1;
        ll tmp = 0;
        for(ll j=0; j<=k; j++){
            tmp += (j+1)*comb.C(k, j);
            tmp %= MOD;
            //cout << (j+1)*comb.C(k, j) << endl;
        }
        //https://www.wolframalpha.com/input/?i=%5Csum_%7Bj%3D0%7D%5E%7Bk%7D+%28j%2B1%29*C%28k%2C+j%29&lang=ja
        //tmp = power(2LL, k-1, MOD)*(k+2)%MOD;
        tmp *= power(2LL, k+1, MOD)*power(4LL, i, MOD)%MOD*C[i]%MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
}
/*
7
1 1 1 1 1 1 1
*/

Measured memory_bytes: 4992
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
    

main = do
    n <- readInt
    a <- readInt
    b <- readInt
    c <- readInt
    d <- readInt
    e <- readInt
    let common = minimum [a,b,c,d,e]
    let groups = n `div` common + (if n `mod` common == 0 then 0 else 1)
    print $ (groups - 1) + 5


Measured memory_bytes: 380
x = gets.to_i

10000.times do |i|
  if x - i**5 >0
    10000.times do |j|
      tmp = i**5 + j**5
      if tmp == x
        puts "#{i} #{-j}"
        exit 0
      end
      next if tmp > x
    end
  else
    10000.times do |j|
      tmp = i**5 - j**5
      if tmp == x
        puts "#{i} #{j}"
        exit 0
      end
      next if tmp < x
    end
  end
end

Measured memory_bytes: 14424
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int n;
  cin >> n;
  cout << n/3 << endl;
  return 0;
}


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

void p(vector<int> &a, vector<int> &b) {
  reverse(a.begin(), a.end());
  rep(i,a.size()) {
    if(i != 0) printf(" ");
    printf("%d", a[i]);
  }
  rep(i,b.size()) {
    printf(" %d", b[i]);
  }
  printf("\n");
}

int main () {
  int n;
  cin >> n;
  vector<int> e((n+1)/2), o(n/2);
  rep(i,n) {
    if(i % 2 == 0) {
      cin >> e[i / 2];
    } else {
      cin >> o[(i-1) / 2];
    }
  }

  if(n % 2 == 0) {
    p(o, e);
  } else {
    p(e, o);
  }

  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main(){
    int n,i;
    while(cin >> n,n){
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<cmath>
#include<queue>
#include<tuple>
using namespace std;
class QuickUnionFind {
private:
	int size_; std::vector<int> g; std::vector<std::vector<int> > v;
public:
	QuickUnionFind() : size_(0), g(std::vector<int>()), v(std::vector<std::vector<int> >()) {};
	QuickUnionFind(int size__) : size_(size__) {
		g.resize(size_); v.resize(size_);
		for (int i = 0; i < size_; i++) g[i] = i, v[i] = { i };
	};
	int size() { return size_; }
	int root(int x) { return g[x]; }
	int size(int x) { return v[x].size(); }
	bool same(int x, int y) { return g[x] == g[y]; }
	void unite(int x, int y) {
		x = g[x], y = g[y];
		if (x == y) return;
		if (v[x].size() < v[y].size()) std::swap(x, y);
		v[x].insert(v[x].end(), v[y].begin(), v[y].end());
		for (auto &e : v[y]) g[e] = x;
		v[y].clear();
	}
	std::vector<int> connected(int x) { return v[g[x]]; }
	bool operator==(const QuickUnionFind& u) { return g == u.g; }
	bool operator!=(const QuickUnionFind& u) { return g != u.g; }
};
int n, x[100009], y[100009]; vector<pair<int, int>>X, Y; vector<tuple<int, int, int>>Z;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		X.push_back(make_pair(x[i], i));
		Y.push_back(make_pair(y[i], i));
	}
	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	for (int i = 1; i < X.size(); i++)Z.push_back(make_tuple(X[i].first - X[i - 1].first, X[i].second, X[i - 1].second));
	for (int i = 1; i < Y.size(); i++)Z.push_back(make_tuple(Y[i].first - Y[i - 1].first, Y[i].second, Y[i - 1].second));
	sort(Z.begin(), Z.end());
	QuickUnionFind UF(n); long long ret = 0;
	for (int i = 0; i < Z.size(); i++) {
		if (UF.same(get<1>(Z[i]), get<2>(Z[i])) == false) {
			ret += get<0>(Z[i]);
			UF.unite(get<1>(Z[i]), get<2>(Z[i]));
		}
	}
	cout << ret << endl;
	return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M ;
  vector <int> cnt (M,0);
  int ans = 0;
  for(int i = 0; i < N; i++){
    int K;
    cin >> K;
    for(int j = 0; j < K; j++){
      int A;
      cin >> A;
      A--;
      cnt[A]++;
    }
  }
  for(int i = 0; i < M; i++){
    if(cnt[i] == N){
      ans++;
    }
  }
  cout << ans << endl;
}
     
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    int d=abs(a-b);
    if(v<=w){
        puts("NO");
        return 0;
    }
    if(t*(v-w)>=d){
        puts("YES");
    }
    else{
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 3648
o=input()
e=input()
ans=''
for i in range(1,len(e)*2+1):
    if i%2==1:
        ans+=o[i//2]
    else:
        ans+=e[i//2-1]
if len(o)==len(e):
    print(ans)
else:
    ans+=o[len(o)-1]
    print(ans)


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

int main(){
    char a, b;
    cin >> a >> b;

    int x, y;
    if(a <= '9')    x = a-'0';
    else            x = 10+a-'A';
    if(b <= '9')    y = b-'0';
    else            y = 10+b-'A';
    
    if(x < y)       cout << "<" << endl;
    else if(x > y)  cout << ">" << endl;
    else            cout << "=" << endl;

    return 0;
}

Measured memory_bytes: 256
heap = [nil] * 257

h = gets.to_i
gets.split().each.with_index(1) do |n, i|
  n = n.to_i
  heap[i] = n
end

(1 .. h).each do |i|
  print "node #{i}: key = #{heap[i]}, "
  if parent = heap[i / 2]
    print "parent key = #{parent}, "
  end
  if left = heap[i * 2]
    print "left key = #{left}, "
  end
  if right = heap[i * 2 + 1]
    print "right key = #{right}, "
  end
  puts ''
end



Measured memory_bytes: 6872
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int k;
    cin>>k;
    bool flag=false;
    for(int i=k;i>0;i-=4)
    {
        if(i%4==0||i%7==0||i%(4+7)==0) {flag=true;break;}
    }
    for(int i=k;i>0;i-=7)
    {
        if(i%4==0||i%7==0||i%(4+7)==0) {flag=true;break;}
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int n,m,vis[200005];
vector<int> adj[200005];

int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  queue<int> q;
  for(int i=0;i<adj[1].size();i++){
    q.push(adj[1][i]);
  }
  while(!q.empty()){
    int cur=q.front();q.pop();
    for(int i=0;i<adj[cur].size();i++) vis[adj[cur][i]] = 1;
  }
  if(vis[n]) printf("POSSIBLE");
  else printf("IMPOSSIBLE");
}

Measured memory_bytes: 12400
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " "<<a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
#define fr first
#define sc second
 
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
 
typedef long long int64;
const int INF = 1 << 30;

int main(){
  int N, K;
  vector< int > Book[10];
  int dp[2001];
  memset( dp, -1, sizeof(dp));

  cin >> N >> K;
  for(int i = 0; i < N; ++i){
    int C, G;
    cin >> C >> G;
    Book[G - 1].push_back(C);
  }
  dp[0] = 0;
  for(int i = 0; i < 10; ++i){
    sort(ALL(Book[i]), greater< int >());
    for(int j = K - 1; j >= 0; --j){
      if(dp[j] == -1) continue;
      int sum = 0;
      for(int k = 0; k < Book[i].size() && j + k + 1 <= K; k++){
        sum += Book[i][k];
        dp[j + k + 1] = max( dp[j + k + 1], dp[j] + sum + (k + 1) * k);
      }
    }
  }
  cout << dp[K] << endl;
}

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

int main() {
	int d, n, sum = 1;
	cin >> d >> n;

	for (int i = 0; i < d; i++) {
		sum = sum * 100;
	}
	if (n == 100) {
		n++;
	}

	cout << sum * n << endl;


	return 0;
}

Measured memory_bytes: 256
'use strict';

function main(stdin) {
  const input = stdin.split(' ').map(v => parseInt(v, 10));
  const N = input[0];
  const D = input[1];

  const a = N / (2 * D + 1);
  
  console.log(Math.ceil(a));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <stdio.h>
#include <math.h>

#define PI 3.1415926535897932386

using namespace std;

int main(void){
	int i,j,angle=0;
	double x=0.0, y=0.0;
	while(scanf("%d,%d",&i,&j) != EOF){
		if(i==0&&j==0) break;
		x+= (double)(i)*sin((double)angle*PI/180);
		y+= (double)(i)*cos((double)angle*PI/180);
		angle += j;
	}
	cout << (int)x << "\n" << (int)y << "\n";
	return 0;
}

Measured memory_bytes: 0