akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    ll N,A,B,C,D,E; cin >> N >> A >> B >> C >> D >> E;
    cout << max({(N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E}) + 5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,idx,ans;
ll x[500005],y[500005],z[500005];
bool used[500005];
char s[500005];


long double distance(ll i, ll j){
    long double tmp = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(tmp);
}
int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
        z[i] = i;
    }
    long double ans = 0;
    do{
        for(int i=0;i<n-1;i++){
            ans += distance(z[i], z[i + 1]);
        }

    }while(next_permutation(z, z + n));
    ll num = 1;
    for(int i=1;i<=n;i++){
        num *= i;
    }
    ps(ans / (long double )num);
    

    return 0;
}


















Measured memory_bytes: 16512
fun main(args: Array<String>) {
  val n = readLine()!!
  val dList = readLine()!!.split(" ").map { it.toInt() }
  val sortedList = dList.sorted()
  val dLeft = sortedList[dList.size/2 - 1]
  val dRight = sortedList[dList.size/2]
  println(dRight - dLeft)
}

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 1000000000 + 7;

void solve() {
	int k;
	cin >> k;
	int total = 0;
	for (int i = 1; i <= (int) 1e7; i++) {
		total = (total * 10 + 7) % k;
		if (total == 0) {
			cout << i << endl;
			return;
		}
	}
	cout << "-1\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int x, y;
	int indeg[n + 1] = {0};
	vector<int> g[n + 1];
	for (int i = 0; i < m; i++)
	{
		cin >> x >> y;
		g[x].push_back(y);
		indeg[y]++;
	}

	int lp[n + 1];

	queue<int> q;
	for (int i = 1; i <= n; i++)
	{
		if (indeg[i] == 0)
		{
			lp[i] = 0;
			q.push(i);
		}
	}
	int ans = 0;
	while (!q.empty())
	{
		int u = q.front();
		q.pop();
		for (int v : g[u])
		{
			indeg[v]--;
			if (indeg[v] == 0)
			{
				lp[v] = 1 + lp[u];
				ans = max(ans, lp[v]);
				q.push(v);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
n = int(input())
ab = []
for i in range(n-1):
    a, b = map(int,input().split())
    ab.append([a, b])

graph = [[] for _ in range(n+1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

root = 1
parent = [0] * (n+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        
color = [-1] * (n+1)
for x in order:
    ng = color[x]
    c = 1
    for y in graph[x]:
        if y == parent[x]:
            continue # 子に対応させる
        if c == ng:
            c += 1
        color[y] = c
        c += 1

print(max(color))
for a,b in ab:
    if parent[a] == b:
        print(color[a])
    else:
        print(color[b])

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int A[410];
int memo[410][410];
int imos[410];

int DP(int l,int r)
{
	if(memo[l][r]!=INF)return memo[l][r];

	int res=INF;

	rep(i,l,r)
	{
		chmin(res,DP(l,i)+DP(i+1,r));
	}

	res+=imos[r+1]-imos[l];

	memo[l][r]=res;
	return memo[l][r];
}

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

	cin>>N;
	rep(i,0,410)rep(j,0,410)memo[i][j]=INF;
	rep(i,0,N)
	{
		cin>>A[i];
		imos[i+1]+=imos[i]+A[i];
		memo[i][i]=0;
	}
	DP(0,N-1);
	cout<<memo[0][N-1]<<endl;

	return 0;
}

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

using namespace std;

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

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto& x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << '\n'; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

const int INF = 0x3F3F3F3F;
const int MAXN = (int) 1e6;
const int MOD = (int) 1e9+7;

//=========================

void run_test() {
	ll x, k, d; read(x, k, d);
    x = abs(x);
    ll v = x / d;
    v = min(v, k);
    x -= v * d;
    k -= v;
    if(k % 2 != 0) x -= d;
    println(abs(x));
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 101

int n, M[MAX][MAX] = {0}, d[MAX] = {0};
int color[MAX] = {WHITE};

int head = 0;
int tail = 0;
int Q[MAX] = {0};

void initialise() {
	head = tail = 0;
}

int isEmpty() {
	return head == tail;
}

int isFull() {
	return head == (tail + 1) % MAX;
}

void enqueue(int x) {
	if (isFull()) {
		printf("Over flow\n");
		exit(0);
	}
	
	Q[tail] = x;
	if (tail + 1 == MAX) {
		tail = 0;
	} else {
		tail++;
	}
	return;
}

int dequeue() {
	int x;
	if (isEmpty()) {
		printf("Under flow\n");
		exit(0);
	}
	x = Q[head];
	if (head + 1 == MAX) {
		head = 0;
	} else {
		head++;
	}
	return x;
}




void bfs(int x) {
	int i, u, v;

	for (i = 0; i < n; ++i) {
		d[i] = -1;
		//printf("%d %d\n", i+1, d[i]);
	}
	
	initialise();
	color[x] = GRAY;
	d[x] = 0;
	enqueue(x);

//	printf("x = %d\n", x);
	while (!isEmpty()) {
		u = dequeue();
//		printf("u = %d\n", u);
		for (v = 0; v < n; ++v) {
			if (M[u][v] && color[v] == WHITE) {
//				printf("u = %d, v = %d\n", u, v);
				color[v] = GRAY;
				d[v] = d[u] + 1;
				enqueue(v);
			}
		}
		color[u] = BLACK;
	}

	for (i = 0; i < n; ++i) {
		printf("%d %d\n", i+1, d[i]);
	}
}

int main() {
	int i, j, u, k, v;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		u--;
		for (j = 0; j < k; ++j) {
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);
	
	return 0;
}

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


int main() 
{
    string S;
    cin >> S;
    
    if (S[1] == S[2]) {
        if (S[0] == S[1] || S[2] == S[3]) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
    int N, arr[50] = {55}, arr2[50] = {55};
    int judge = 0;
    cin >> N;
    for (int i =0; i < N; i++) {
        cin >> arr[i];
        arr2[i] = arr[i];
    }

    sort(arr, arr + N);

    for (int i=0 ; i < N; i++) {
        if (arr[i] != arr2[i]) {
            judge++;
        }
    }
  	
    if (judge==2 || judge == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> cho(d +1,0);
  int cnt = 0;
  rep(i,n){
    rep(j,100){
      if(j*a[i] + 1 <= d)cnt++;
    }
  }
  cout << cnt + x << endl;
}

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

const int MAX = 500005;

struct Query
{
    int l, r, idx;
};

Query queries[MAX];
int bit[MAX], last_visit[MAX], ans[MAX], a[MAX], n, q;

bool cmp(Query x, Query y)
{
    return x.r < y.r;
}

void update(int idx, int val, int bit[], int n)
{
    for (; idx <= n; idx += idx & -idx)
        bit[idx] += val;
}

int query(int idx, int bit[], int n)
{
    int sum = 0;
    for (; idx > 0; idx -= idx & -idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
    memset(bit, 0, sizeof(bit));

    memset(last_visit, -1, sizeof(last_visit));

    int query_counter = 0, i;

    for (i = 0; i < n; i++)
    {
        if (last_visit[arr[i]] != -1)
            update(last_visit[arr[i]] + 1, -1, bit, n);

        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                query(queries[query_counter].r + 1, bit, n) -
                query(queries[query_counter].l, bit, n);
            query_counter++;
        }
    }

    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;
}

int main(void)
{
    int i;

    scanf("%d %d", &n, &q);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);

    for (i = 0; i < q; i++)
    {
        int l, r;

        scanf("%d %d", &l, &r);

        l--, r--;

        queries[i].l = l;
        queries[i].r = r;
        queries[i].idx = i;
    }

    sort(queries, queries + q, cmp);

    answeringQueries(a, n, queries, q);
    return 0;
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD


ll factional(int n){ll ret = 1; FOR(i, 2, n+1) ret *= i; return ret;}
ll permutation(int n, int r){ll ret = n; FOR(i,1,r) ret *= n-i; return ret;}
ll combination(int n, int r){return permutation(n, r) / factional(r);}
int n;

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

    if(n<10){
        cout << n << endl;
        return 0;
    }
    ll ans = 0;

    vi nums(100);
    //[先頭桁、末尾桁]
    nums[11]++;
    nums[22]++;
    nums[33]++;
    nums[44]++;
    nums[55]++;
    nums[66]++;
    nums[77]++;
    nums[88]++;
    nums[99]++;

    FOR(i,11,n+1){
        //int idx;
        int idx10 = to_string(i)[0]-'0';
        int idx1 = i%10;

        if((i%10) == 0) continue;

        nums[idx10*10 + idx1]++;
    }

    FOR(i,11,nums.size()){
        if(nums[i]>0){
            int idx10 = to_string(i)[0]-'0';
            int idx1 = i%10;

            if(idx10 == idx1)
                ans += pow(nums[i],2LL);
            else
                ans += nums[i] * nums[idx1*10 + idx10];
            
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int cnt[100005];
int main() {
    int n , m , c , t , count = 0;
    cin >> n >> m >> c;
    vector <int>  B(m);
    rep(i , m){
        cin >> B[i];
    }
    rep(i , n){
        int s = 0;
        rep(j , m){
            cin >> t;
            s += t * B[j];
        }
        if(s + c > 0){
        	count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3612
#41 ABC132D
n,k=map(int,input().split())

c=[[0 for i in range(j+1)] for j in range(n+1)]
c[0][0]=1
for i in range(1,n+1):
	for j in range(i+1):
		if j==0:
			c[i][j]=c[i-1][j]
		elif j==i:
			c[i][j]=c[i-1][j-1]
		else:
			c[i][j]=c[i-1][j]+c[i-1][j-1]
for i in range(1,k+1):
	try:
		print(c[n-k+1][i]*c[k-1][i-1]%(10**9+7))
	except:
		print(0)

Measured memory_bytes: 435940
using System;

namespace B___Greedy_Takahashi
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = long.Parse (input[0]);
            var b = long.Parse (input[1]);
            var k = long.Parse (input[2]);
            if (a - k >= 0)
                Console.WriteLine ($"{a-k} {b}");

            else if (b + a - k >= 0)
                Console.WriteLine ($"0 {b+a-k}");

            else
                Console.WriteLine ("0 0");
        }
    }
}

Measured memory_bytes: 13140
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com

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

#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double

#define pii   pair<int, int>
#define piii  pair<int, pair<int, int>>
#define pll   pair<ll, ll>

#define F  first
#define S  second
#define PB push_back
#define MP make_pair

#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename T>
string to_string(const vector<T> &v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}

// add templates here

template<class T>
void println(const T &data) {
    cout << to_string((T)data) << endl;
}

template <typename T>
void write(vector<T> &v, bool size=true) {
    if(size) cout << v.size() << endl;
    string res = "";
    for(const T &x: v) {
        res += to_string((T)x) + " ";
    }
    cout << res << endl;
}


const int MOD = int(1e9+7);
const int oo  = int(1e9 + 20);
const ll lloo  = (ll)(1e18 + 10);

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

    int r;
    cin >> r;
    cout << (3*r*r) << endl;
    

    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[1] == 'R') {
		cout << "ABC";
	} else {
		cout << "ARC";
	}
	return 0;
}


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

void initialize(){
  for(int i = 0;i < N;i++) row[i] = col[i] = FREE;
  for(int i = 0;i < 2*N-1;i++) dpos[i] = dneg[i] = FREE;
}

void printBoard(){
  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      if(X[i][j]){
        if(row[i] != j) return;
      }
    }
  }
  for(int i = 0;i < N;i++){
    for(int j= 0;j < N;j++){
      cout << ((row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void recusive(int i){
  if(i == N){
    printBoard();return;
  }
  for(int j = 0;j < N;j++){
    if(NOT_FREE == col[j] ||
      NOT_FREE == dpos[i + j] ||
      NOT_FREE == dneg[i - j + N -1]) continue;
      row[i] = j;col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
      recusive(i + 1);
      row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
  }

  int main(){
    initialize();

    for(int i = 0;i < N;i++){
      for(int j = 0;j < N;j++){
        X[i][j] = false;
      }
    }
    int k;cin >> k;
    for(int i = 0;i < k;i++){
      int r,c;cin >> r >> c;
      X[r][c] = true;
    }

    recusive(0);

    return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
  int n,a,b,i,j,k;bool hi=false;
  cin>>a>>b;
  float c=a,d=a+0.9;
  int y=b*10;
  k=b*10+9;
  for(i=y;i<=k;i++)
  {
      if((i*(0.08))>=c&&(i*(0.08))<=d)
       {
           cout<<i;hi=true;
           break;
       }
  }
  if(!hi)
   cout<<"-1";
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,M=get_i
A=get_f.sort!{|x,y| y<=>x}
sum=A.inject(:+)
ans=0
N.times do|i|
    if A[i]>=(sum.to_f/(4.0*M).to_f)
        ans+=1
    end
end
puts yn_judge(ans>=M)

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
 	ll a,b,c,x,y,d;
 	sc(a);sc(b);sc(c);sc(d);
 	x=a+b;
 	y=c+d;
 	if(x==y){
 		printf("Balanced\n");
 	}
 	else if(x>y){
 		printf("Left\n");
 	}
 	else{
 		printf("Right\n");
 	}	 		

}

Measured memory_bytes: 256
a,b,k = list(map(int, input().split()))
c = k%2
while k > 0:
    if k%2 == c:
        if a%2 == 1:
            a -= 1
        b += a//2
        a -= a//2
    else:
        if b%2 == 1:
            b -= 1
        a += b//2
        b -= b//2
    k -= 1
print(a,b)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int n, m, k;
int main(){
    scanf("%d%d%d", &n, &m, &k);
    for(int a = 0; a <= n; a ++){
        for(int b = 0; b <= m; b ++){
            if(n*b + m*a - 2*a*b == k){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}


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

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> s) {
  if (s.size() == n+1 ) {
    int now = 0;
    rep(i,q) {
      if (s[b[i]] - s[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans,now);
    return;
  }
  s.push_back(s.back());
  while (s.back() <= m){
    dfs(s);
    s.back()++;
  }
}


int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep (i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt64(ReadLine());
        long dif = num / 11;
        if (dif == (double)num / 11) WriteLine(dif * 2);
        else WriteLine(num - 11*dif > 6 ? 2*(dif+1) : 2*dif+1);
    }
}

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 2000005;

bool check(string s)
{
	int n = s.length();
	int start = 0, end = n - 1;
	int f = 1;
	while (start <= end)
	{
		if (s[start] != s[end])
		{
			f = 0;
			break;
		}
		start++;
		end--;
	}
	if (f == 0) return false;
	else return true;
}


void solve()
{
	string s;
	cin >> s;
	bool a1 = check(s);
	int n = s.length();
	int l = (n - 1) / 2;
	string t1 = s.substr(0, l);

	bool a2 = check(t1);
	int start = (n + 3) / 2;
	string t2 = "";
	loop(i, start - 1, n) t2 += s[i];
	bool a3 = check(t2);
	//bug(a1, t1, a2, t2, a3);
	if (a1 and a2 and a3) cout << "Yes" << endl;
	else cout << "No" << endl;
	return;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



	//cout << setprecision(9) << fixed;
	clock_t z = clock();
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int k,s;
    cin>>k>>s;

    ll ans = 0;
    REP(i,k+1){
        REP(j,k+1){
            //DEBUG(s-(i+j));
            if(s-(i+j) <= k && s-(i+j) >= 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MXN = 1e5 + 5;
int n;
int h[MXN];
int dp[MXN];

int Dp(int idx) {
    if(idx == n - 1) return 0; // caso base
    if(dp[idx] != -1) return dp[idx]; // caso dp
    int ans = Dp(idx + 1) + abs(h[idx] - h[idx + 1]);
    if(idx + 2 < n) ans = min(ans, Dp(idx + 2) + abs(h[idx] - h[idx + 2])); 
    return dp[idx] = ans; // guardar
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    memset(dp, -1, sizeof dp);
    cout << Dp(0) << endl;
    return 0;
}

Measured memory_bytes: 9012
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

long harshad(long x) {
    if (x == 0) {
        return 0;
    }
    return x % 10 + harshad(x / 10);
}


int main()
{
    long n, f;
    cin >> n;
    f = harshad(n);
    if (n % f) {
        cout << "No" << endl;
        return 0;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long cnt = 1;
  long long ans = 0;
  while (n > 0) {
    ans += cnt;
    n /= 2;
    cnt *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W	 = in.readLine();
		int N = Integer.parseInt(W.split(" ")[0]);
		String[] S = new String[N];
		HashMap<String, Integer> keihinMap = new HashMap<String, Integer>();

		for(int i = 0;i<N ; i++) {
			keihinMap.put(in.readLine(), 1);
		}

//		Scanner sc = new Scanner(System.in);
//		int N = sc.nextInt();

		System.out.println(keihinMap.size());







	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}

}


Measured memory_bytes: 65272
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long

const lint MOD = 1e9 + 7;
const int MAX_N = 100005;
lint dp[MAX_N][4];

int main(){
    string s; cin >> s; int n = (int)s.size();
    dp[0][0] = 1;
    rep(i, n){
        int j = i + 1;
        if(s[i] == '?'){
            dp[j][0] = dp[j-1][0] * 3;
            repn(k, 3) dp[j][k] = dp[j-1][k-1] + (dp[j-1][k] * 3) % MOD;
        }
        else{
            rep(k, 4) dp[j][k] = dp[j-1][k];
            dp[j][s[i]-'A'+1] += dp[j-1][s[i]-'A'];
        }
        rep(k, 4) dp[j][k] %= MOD;
    }
    cout << dp[n][3] << endl;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define abs(x)    ((x) < 0 ? -(x) : (x))
#define INF 0x3f3f3f3f
#define delta 0.85
#define eps 1e-10
#define PI 3.14159265358979323846
using namespace std;

#define MAX_V 2000
int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		int u = G[v][i], w = match[u];
		if(w < 0 || (!used[w] && dfs(w))){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res = 0;
	memset(match, -1, sizeof(match));
	for(int v = 0; v < V; v++){
		if(match[v] < 0){
			memset(used, 0, sizeof(used));
			if(dfs(v)){
				++res;
			}
		}
	}
	return res;
}

#define MAX_N 100
#define MAX_L 1000
int N, M, L;
int dp[MAX_N][MAX_N];
int P[MAX_L], T[MAX_L];

void clear_graph(){
	for(int v = 0; v < V; v++) G[v].clear();
}

void floyd_warshall(){
	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
}

void solve(){
	floyd_warshall();
	V = 2 * L;
	clear_graph();
	
	for(int i = 0; i < L; i++){
		for(int j = i + 1; j < L; j++){
			if(dp[P[i]][P[j]] <= abs(T[j] - T[i])){
				if(T[i] <= T[j]) add_edge(i, L + j);
				else add_edge(j, L + i);
			}
		}
	}
	
	printf("%d\n", L - bipartite_matching());
}

int main(){
	while(~scanf("%d%d%d", &N, &M, &L) && (N | M | L)){
		memset(dp, 0x3f, sizeof(dp));
		for(int i = 0; i < N; i++) dp[i][i] = 0;
		for(int i = 0; i < M; i++){
			int u, v, d;
			scanf("%d%d%d", &u, &v, &d);
			dp[u][v] = dp[v][u] = d;
		}
		for(int i = 0; i < L; i++) scanf("%d%d", P + i, T + i);
		solve();
	}
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans=1;
    for(int i=1; i<N; i++){
        if(S.at(i) != S.at(i-1)){
            ans++;
        }
    }
    cout << ans << endl;

}

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

constexpr size_t maxM = 1000000, days = 100;

int_fast64_t dp[1010101], sum[1010101], ans[days], Day;

void dfs(int l, int r, int n){
    //cout << l << ", " << r << ", " << n << " : " << ((r - l) & ((2 << n) - 1)) << endl;
    if(l >= r - 1)return;
    if(r - l == 2){
        dp[l] += 1;
        dp[l + 1] -= 1;
        sum[l] += 1;
        sum[r] -= 1;
        return;
    }
    int m = l, k = l;
    for(int i = 0; i + 1 < 2 << n; ++i){
        k = m;
        m += ((r - l) / 2 >> n) + (i < ((r - l) & ((2 << n) - 1)));
        dp[k] += 1;
        dp[m] += -1;
        sum[k] += 1;
        sum[r] += -1;
        dfs(k, m, n + 1);
    }
    dfs(m, r, n + 1);
}

int main(){
    //dfs(0, 1000000);
    dfs(0, maxM, 0);
    partial_sum(dp, dp + 1010101, dp);
    partial_sum(sum, sum + 1010101, sum);
    for(int i = 0; i < 30; ++i)cout << dp[i] << " ";
    cout << endl;
    for(int i = 0; i < 30; ++i)cout << sum[i] << " ";
    cout << endl;
    for(int i = 0; i < maxM; ++i){
        if(dp[i] < 6){
            ++ans[sum[i]];
            Day += sum[i];
        }
        else ++ans[0];
    }
    for(int i = 0; i < days; ++i){
        printf("%d : %.12Lf\n%lld\n", i, ans[i] / static_cast<long double>(1000000), Day);
    }
}*/

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

long long n;

int main() {
    while(cin >> n, n){
        cout << n << "\t: " << bitset<27>(n) << endl;
    }
}*/

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

int main(){
    long long N, Q;
    scanf("%lld%lld", &N, &Q);

    vector<long long> A(N), AS(N + 2), S(N + 1), X((N - 1) / 2), a((N + 1) / 2);
    for(int i = 0; i < N; ++i){
        scanf("%lld", &A[i]);
        AS[i + 2] = A[i] + AS[i];
        S[i + 1] = A[i] + S[i];
    }
    
    for(int i = 1; i <= (N + 1) / 2; ++i){
        a[i - 1] = *S.rbegin() - *(S.rbegin() + i) + *(AS.rbegin() + i * 2);
    }

    for(int i = 1; i <= (N - 1) / 2; ++i){
        X[i - 1] = *(A.rbegin() + i) + *(A.rbegin() + i * 2);
    }

    reverse(a.begin(), a.end());
    reverse(X.begin(), X.end());

    for(long long i = 0, x = 0; i < Q; ++i){
        scanf("%lld", &x);
        printf("%lld\n", a[lower_bound(X.begin(), X.end(), x * 2) - X.begin()]);
    }
    return 0;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
#include <queue>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e5+5;
int n, m, p[N], q[N], lg[N], ans[N];
vector<int> to[N]; pair<int, int> s[N];
priority_queue<pair<int, int> > h;
struct ST
{
    int _[18][N];
    void build(int k)
    {
        for(int i = 2-k; i <= n; i += 2) _[0][i] = p[i];
        for(int i = 2-(k^1); i <= n; i += 2) _[0][i] = n+1;
        for(int i = 1, m = lg[n]; i <= m; ++i)
            for(int j = 1; j+(1<<i)-1 <= n; ++j)
                _[i][j] = min(_[i-1][j], _[i-1][j+(1<<(i-1))]);
    }
    int ask(int l, int r)
    {
        int i = lg[r-l+1];
        return min(_[i][l], _[i][r-(1<<i)+1]);
    }
}f[2];
int solve(int l, int r)
{
    int a = f[l&1].ask(l, r), b = f[(l&1)^1].ask(q[a]+1, r), c = ++m; s[c] = make_pair(a, b);
    if(l != q[a]) to[c].push_back(solve(l, q[a]-1));
    if(q[a]+1 != q[b]) to[c].push_back(solve(q[a]+1, q[b]-1));
    if(q[b] != r) to[c].push_back(solve(q[b]+1, r));
    return c;
}
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) p[i] = read(), q[p[i]] = i;
    for(int i = 2; i <= n; ++i) lg[i] = lg[i>>1]+1;
    f[0].build(0), f[1].build(1), solve(1, n), m = 0, h.push(make_pair(-s[1].first, 1));
    while(h.size())
    {
        int x = h.top().second; h.pop(); ans[++m] = s[x].first, ans[++m] = s[x].second;
        for(int i = 0; i < to[x].size(); ++i) h.push(make_pair(-s[to[x][i]].first, to[x][i]));
    }
    for(int i = 1; i <= n; ++i) printf("%d ", ans[i]); puts("");
    return 0;
}

Measured memory_bytes: 47872
function Main(input) {
	var week = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
    inputLine = input.split("\n");
    for(var i=0;;i++){
    	var time = new Date();
    	time.setFullYear(2004);
    	var date = inputLine[i].split(" ");
    	var month = Int(date[0]);
    	var day = Int(date[1]);
    	if(month == 0)break;
    	time.setMonth(month-1);
    	time.setDate(day);
    	output(week[time.getDay()]);
    }
}
//??°??????????????¢??°??¨(??????)
function ascendingOrder(val1,val2){
    return val1 - val2;
}
//??°??????????????¢??°??¨(??????)
function descendingOrder(val1,val2){
    return val2 - val1;
}
//??°??????
function Int(str){
    return parseInt(str, 10);
}
//????????????
function Str(num){
    return num.toString(10);
}
function output(str){
	if(_Isdebug){
		document.getElementById("Console").value+=(str+"\n");
	}
	console.log(str);
}

//???????????°??¨
var _Isdebug = false;

function debug(){
	_Isdebug = true;
	var input = document.getElementById("Console").value;
	document.getElementById("Console").value+="\n";
	Main(input);
}

//??\??????????????????
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define fr(i,a) for(int  i=0;i<a;i++)
#define Sort(a) sort(a.begin(),a.end())
#define Rev(k)  reverse(k.begin(),k.end());
#define Mod 1000000007
#define Fi first
#define Sc second
#define pb push_back

typedef long  ll;
int d;

bool Int(int a[][10] ,int i,int j,int n,int d){
    ll s=0;
    for(int k = 0;k<d;k++){
        s+=pow((a[i][k]-a[j][k]), 2);
    }
    long double sr = sqrt(s);
  return ((sr - floor(sr)) == 0);
}

int main()
{
    int n;
    cin>>n>>d;
    int a[n][10];

    fr(i,n){
        fr(j,d){
        cin>>a[i][j];
        }
    }
    int ctr =0;
    fr(i,n-1)
    {
        for(int j = i+1 ;j<n;j++){
            if(Int(a,i,j,n,d))
                ctr++;
        }
    }

cout<<ctr<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int, int>
#define pll pair<ll , ll>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define N 200005
#define INF 1000000000000000


int main()
{   
    fastio
    
    int h , w;
    cin>>h>>w;
    ll mod = 1e9+7;
    vector<vector<int>> arr(h , vector<int>(w , 0));

    for(int i = 0 ;i<h;i++)
    {   
        string s;cin>>s;
        for(int j = 0 ; j<w;j++)
        {
            if(s[j]=='#')arr[i][j] =1;
        }
    }

    vector<vector<ll>> dp(h,vector<ll>(w , 0));

    dp[0][0]=1;

    for(int i = 0;i<w;i++)
    {
        if(arr[0][i] == 1)break;
        dp[0][i] =1;
    }

    for(int i = 0;i<h;i++)
    {
        if(arr[i][0] == 1)break;
        dp[i][0]=1;
    }

    for(int i = 1;i<h;i++)
    {
        for(int j =1;j<w;j++)
        {
            if(arr[i][j] == 1)continue;

            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
        }
    }

    cout<<dp[h-1][w-1]<<endl;
    return 0;
} 

Measured memory_bytes: 12032
#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> // double
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ios::sync_with_stdio(false);
  while(1) {
      int a,b;
      cin >> a >> b;
      if(a == 0 && b == 0) break;
      vector<vector<string>> data(a,vector<string>(b,"#"));
      rep(i,a) {
          rep(j,b) {
              if(i % 2 == 0 && j % 2 == 1) data[i][j] = ".";
              if(i % 2 == 1 && j % 2 == 0) data[i][j] = ".";
          }
      }
      rep(i,a) {
          rep(j,b) cout << data[i][j];
          cout << "\n";
      }
      cout << "\n";
  }
}


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

int main(void)
{
  int N, M;
  cin >> N >> M;
  vector<int> edge[MAX_N + 1];
  rep(i, M)
  {
    int a, b;
    cin >> a >> b;
    if (a == 1 || a == N || b == 1 || b == N) {
      edge[a].push_back(b);
      edge[b].push_back(a);
    }
  }

  for (auto iter0 = edge[1].begin(); iter0 != edge[1].end(); ++iter0) {
    int v = *iter0;
    for (auto iter = edge[v].begin(); iter != edge[v].end(); ++iter) {
      if (*iter == N) {
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 12016
A, B, C, X, Y = list(map(int, input().split()))

ans = A*X + B*Y
c = min(X, Y)
ans = min(A*(X-c) + B*(Y-c) + c*C*2, ans)
c = max(X, Y)
ans = min(c*C*2, ans)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef long long ll;

ll p = pow(10, 9) + 7;




int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n <= k)
    {
        cout << x * n << endl;
    } else{
        cout << k * x + (n - k) * y << endl;
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
string s;
int a[200005];
int b[200005];
int main(){
	cin>>n>>s;
	for(int i=0;i<n;i++){
		a[i+1] = a[i]+(s[i]=='#');
	}
	for(int i=n-1;i>=0;i--){
		b[i] = b[i+1]+(s[i]=='.');
	}
	int ans = INF;
	for(int i=0;i<=n;i++){
		ans = min(ans,a[i]+b[i]);
	}
	cout<<ans<<endl;
}

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

int main(void)
{
    IOS
    int a; cin >> a;
    OUT(a+a*a+a*a*a)

    return 0;
}

Measured memory_bytes: 3600