akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int n, m;
	cin >> n >> m;
	vector<long long int> s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	sort(s.begin(),s.end());
	vector<pair<int, int>> k;
	for (int i = 0; i < m; i++) {
		long long int b;
		long long int c;
		cin >> b >> c;
		k.push_back(make_pair(c, b));
	}

	sort(k.begin(), k.end(),greater<>());
	vector<long long int > sn;
	for (int i = 0; i < m; i++) {
		long long int b = k[i].second;
		long long int c = k[i].first;
		for (int j = 0; j < b; j++) {
			sn.push_back(c);
		}
		if (sn.size() > n) {
			break;
		}
	}

	for (int i = 0; i < min(sn.size(),s.size()); i++) {
		if (sn[i] > s[i]) {
			s[i] = sn[i];
		}
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = ans + s[i];
	}
	cout << ans;
}

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

const int N = 1e6 + 5;

struct pp {
	int mx, id;
};

struct mm {
	pp mx1, mx2;
} dp[N];

int n, ans = 0, a[N];

void pass(pp &mx1, pp &mx2, pp x) {
	if (mx1.mx == x.mx) {
		if (mx2.mx < x.mx && mx1.id != x.id) {
			mx2 = x;
		}
	} else if (mx1.mx < x.mx) {
		mx2 = mx1;
		mx1 = x;
	} else if (mx2.mx < x.mx) {
		mx2 = x;
	}
}

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 0; i < 1 << n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 1 << n; i++) {
		dp[i].mx1 = {a[i], 1 << i};
	}
	for (int i = 0; i < n; i++) {
		for (int mask = 0; mask < 1 << n; mask++) {
			if (mask & (1 << i)) {
				pass(dp[mask].mx1, dp[mask].mx2, dp[mask ^ (1 << i)].mx1);
			}
		}
	}
	ans = dp[0].mx1.mx + dp[0].mx2.mx;
	for (int k = 1; k < 1 << n; k++) {
		ans = max(ans, dp[k].mx1.mx + dp[k].mx2.mx);
		cout << ans << '\n';
	}
}


Measured memory_bytes: 8756
<?php
  list($a) = explode(" ", trim(fgets(STDIN)));
  list($b) = explode(" ", trim(fgets(STDIN)));
  list($c) = explode(" ", trim(fgets(STDIN)));
  list($x) = explode(" ", trim(fgets(STDIN)));

  $ans=0;
  for($i=0;$i<=$a;$i++){
    for($j=0;$j<=$b;$j++){
      for($k=0;$k<=$c;$k++){
        if($i*500+$j*100+$k*50 == $x) $ans++;
      }
    }
  }

  echo $ans;

Measured memory_bytes: 16264
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int r;
    cin >> r;
    
    cout << pow(r,2) * 3 << endl;
    return 0;
}


Measured memory_bytes: 256
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

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

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 DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

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

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


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

    double sumJPY = 0;
    double sumBTC = 0;
    REP(i, N){
        double x;
        string u;
        cin >> x >> u;

        if(u == "JPY"){
            sumJPY += x;
        }else{
            sumBTC += x;
        }
    }
    double ans = sumBTC * 380000 + sumJPY;
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n, a[3], b, c[3];
  	int64_t total;
    total = a[0] = a[1] = a[2] = 0;
    string s;
    cin >> n >> s;
    for(int i=0;i<n;i++){
        if(s[i] == 'R'){
            a[0]++;
        }else if(s[i] == 'G'){
            a[1]++;
        }else if(s[i] == 'B'){
            a[2]++;
        }
    }
    
    for(int i=0;i<n-2;i++){
        if(s[i] == 'R'){
            a[0]--;
        }else if(s[i] == 'G'){
            a[1]--;
        }else if(s[i] == 'B'){
            a[2]--;
        }
        for(int j=0;j<3;j++){
            c[j] = a[j];
        }
        for(int j=i+1;j<n-1;j++){
            if(s[j] == 'R'){
                c[0]--;
            }else if(s[j] == 'G'){
                c[1]--;
            }else if(s[j] == 'B'){
                c[2]--;
            }
            if(s[i] == s[j]){
                continue;
            }
            b = 219 - (int)s[i] - (int)s[j];
            if(2*j-i<n){
                if(s[2*j-i] == (char)b){
                    total--;
                }
            }

            switch (b){
            case 66:
                total += c[2];
                break;
            case 71:
                total += c[1];
                break;
            case 82:
                total += c[0];
                break;
            }
        }
    }
    cout << total;

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public final class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        int[] d = new int[n];
        for(int i=0; i<n; i++){
            d[i] = stdIn.nextInt();
        }

        quick_sort(d, 0, d.length-1);

        if(n%2 == 1){
            System.out.println(0);
        }else{
            System.out.println(d[n/2] - d[n/2-1]);
        }
    }

    static void quick_sort(int[] d, int left, int right) {
        if (left>=right) {
            return;
        }
        int p = d[(left+right)/2];
        int l = left, r = right, tmp;
        while(l<=r) {
            while(d[l] < p) { l++; }
            while(d[r] > p) { r--; }
            if (l<=r) {
                tmp = d[l]; d[l] = d[r]; d[r] = tmp;
                l++; r--;
            }
        }
        quick_sort(d, left, r);  // ピボットより左側をクイックソート
        quick_sort(d, l, right); // ピボットより右側をクイックソート
    }
}

Measured memory_bytes: 49416
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int x; cin >> x;

    cout << 1-x << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>

using namespace std;
int main() {
	string s;
	cin >> s;

	int out = 0;
	for(int i = 1; i < s.size(); i++) {
		if((s[i - 1] == '0' && s[i] == '1') || (s[i - 1] == '1' && s[i] == '0')) {
			s.erase(i - 1, 2);
			out+=2;
			i -= 2;
		}
	}
	cout << out << endl;
}


Measured memory_bytes: 512
n = int(input())
u = []
for i in range(n):
    tmp = input()
    u.append( tmp )

m = int( input() )
t = []
for i in range(m):
    tmp = input()
    t.append( tmp )

lock = True
for i in t:
    b = False
    for j in u:
        if i == j:
            b = True
            break
    if b and lock:
        print( "Opened by " + i )
        lock = False
    elif b and not lock:
        print( "Closed by " + i )
        lock = True
    else:
        print( "Unknown " + i )

Measured memory_bytes: 7704
#include <stdio.h>


int main(void) {

	// 1_3-A Print Many Hello World

	int i,x,y;

	for(i=0; i<3000; i++){
		scanf("%d %d",&x,&y);

		if(x==0 && y==0){
			break;
		}

		if(x<y){
			printf("%d %d\n",x,y);
		}else{
			printf("%d %d\n",y,x);
		}

	}
        return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 10000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,cap,rev;
	edge(){}
	edge(int tt,int cc,int rr){
		to=tt;
		cap=cc;
		rev=rr;
	}
};

vector<edge> G[1000];
int level[1000];
int iter[1000];

void add_edge(int from,int to,int cap){
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(que.size()){
		int v=que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to]=level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f){
	if(v==t)return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e=G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
			int d=dfs(e.to,t,min(e.cap,f));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	while(1){
		bfs(s);
		if(level[t]<0)return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,INF))>0){
			flow+=f;
		}
	}
}

int h,w,c,m,nw,nc,nm;

int main(void){
	while(1){
		scanf("%d%d%d%d%d%d%d",&h,&w,&c,&m,&nw,&nc,&nm);
		if(h==-1)break;
		int party=h+w+c+m;
		int s=(party+3)*2,t=s+1;
		for(int i=0;i<=t;i++){
			G[i].clear();
		}
		add_edge(party*2,party*2+1,nw);
		add_edge(party*2+2,party*2+3,nc);
		add_edge(party*2+4,party*2+5,nm);
		for(int i=0;i<c;i++){
			add_edge(party*2+1,h+w+i,1);
		}
		for(int i=0;i<m;i++){
			add_edge(party*2+3,h+w+c+i,1);
		}
		add_edge(party*2+5,t,nm);
		for(int i=0;i<h;i++){
			add_edge(i+party,party*2,1);
		}
		for(int i=0;i<party;i++){
			add_edge(i,i+party,1);
		}
		for(int i=0;i<h;i++){
			add_edge(s,i,1);
		}
		for(int i=0;i<w;i++){
			int ni;
			scanf("%d",&ni);
			for(int j=0;j<ni;j++){
				int a;
				scanf("%d",&a);
				a--;
				add_edge(a+party,h+i,1);
			}
			add_edge(party+h+i,party*2+2,1);
		}
		for(int i=0;i<c;i++){
			int ni;
			scanf("%d",&ni);
			for(int j=0;j<ni;j++){
				int a;
				scanf("%d",&a);
				a--;
				add_edge(party+h+a,h+w+i,1);
			}
			add_edge(party+h+w+i,party*2+4,1);
		}
		for(int i=0;i<m;i++){
			int ni;
			scanf("%d",&ni);
			for(int j=0;j<ni;j++){
				int a;
				scanf("%d",&a);
				a--;
				add_edge(party+a+h+w,h+w+c+i,1);
			}
			add_edge(party+h+w+c+i,t,1);
		}
		printf("%d\n",max_flow(s,t));
	}
	return 0;
}

Measured memory_bytes: 3308
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

// ceil of a/b
inline int ceil(int a, int b) { return (a%b?a/b+1:a/b); }


signed main() {
	int n;
	std::cin >> n;
	std::cout << std::setprecision(10) << (double) ceil(n,2)/(double)n;
	return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		String[] arrInt = (new BufferedReader(new InputStreamReader(System.in))).readLine().split(" ");

		int w = Integer.parseInt(arrInt[0]);
		int h = Integer.parseInt(arrInt[1]);
		int x = Integer.parseInt(arrInt[2]);
		int y = Integer.parseInt(arrInt[3]);
		int r = Integer.parseInt(arrInt[4]);
		
		boolean isOut = false;
		//?????´??¢?¨????
		if(w - r < 0) isOut = true;	//width??????r?????§??????
		else if(x - r < 0) isOut = true;	//x-r??§??????????????????
		else if(y - r < 0) isOut = true;	//y-r??§??????????????????
		else if(x + r > w) isOut = true;	//x+r??§??????????????????
		else if(y + r > h) isOut = true;
		
		if(isOut) System.out.println("No");
		else System.out.println("Yes");
	}
}

Measured memory_bytes: 24356
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int N, K, L;
P p[200001];

bool check(long long int min_A){
	bool flag[200001] = {};
	for(int i = 0; i < N; i++){
		if(p[i].first > min_A){
			break;
		}
		flag[p[i].second + 1] = true;
	}
	int S = 0, pos = 0;
	long long int cnt = 0;
	for(int i = 0; i <= N; i++){
		if(flag[i]){
			S--;
		}
		while(S < K){
			if(pos > N){
				return cnt >= L;
			}
			if(flag[pos]){
				S++;
			}
			pos++;
		}
		cnt += N - pos + 2;
	}
	return cnt >= L;
}

long long int bin_search(long long int lef, long long int rig){
	long long int middle = (lef + rig) / 2;
	//cout << middle << " ";
	if(rig - lef <= 1){
		if(check(rig)){
			return rig;
		}else{
			return lef;
		}
	}
	if(check(middle)){
		rig = middle;
	}else{
		lef = middle;
	}
	return bin_search(lef, rig);
}

int main(){
	
	cin >> N >> K >> L;
	
	for(int i = 0; i < N; i++){
		cin >> p[i].first;
		p[i].second = i;
	}
	
	sort(p, p + N);
	
	cout << bin_search(0, 200000) << endl;
	
	return 0;
}


Measured memory_bytes: 6436
#include <bits/stdc++.h>
#define MP make_pair
#define F first
#define PB push_back
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;
const int maxn = 1e5 + 4;
const int inf = (int)1e9;

ll a[10];

int main() {
	ios::sync_with_stdio(false);
	ll ans = 0;
	int n = 7;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ans += (a[0] - (a[0] % 2)) + (a[3] - (a[3] % 2)) + (a[4] - (a[4] % 2)) + a[1];
	ll mn = min (a[0], min (a[3], a[4]));
	if (mn > 0) {
		ll k = (a[0] % 2) + (a[3] % 2) + (a[4] % 2);
		if (k == 2) {
			ans ++;
		}
		if (k == 3) {
			ans += 3;
		}
	}
	cout << ans << endl;
}



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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  vector<double> p(n);
  rep(i, n) cin >> p[i];
  vector<double> pp(n);
  rep(i, n) pp[i] = (p[i] + 1.) / (2.);
  queue<double> que;
  double ans = 0.;
  double tmp = 0.;
  rep(i, n) {
    tmp += pp[i];
    que.push(pp[i]);
    if (que.size() < k) {
      continue;
    }
    else if(que.size()==k){
      chmax(ans, tmp);
    }else{
      tmp -= que.front();
      que.pop();
      chmax(ans, tmp);
    }
  }
  printf("%0.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int V[111],C[111],A[111];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        int x,y;
        scanf("%d",&V[i]);
    }
    for(int i=1;i<=n;i++) {
        scanf("%d",&C[i]);
    }
    for(int i=1;i<=n;i++) {
        A[i]=V[i]-C[i];
    }
    sort(A+1,A+n+1);
//    for(int i=1;i<=n;i++) {
//        cout<<A[i]<<" ";
//    }cout<<endl;
    int ans = 0;
    for(int i=n;i>=1;i--) {
        if(A[i]<0) break;
        else ans += A[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int r;
    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}



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

int main() {
  string N;    
  cin >> N;
  
  if(N.at(0)==N.at(1) && N.at(0)==N.at(2))  cout << "Yes" << endl;
  else if(N.at(1)==N.at(3) && N.at(2)==N.at(3))  cout << "Yes" << endl;
  else  cout << "No" << endl;
}

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

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

Measured memory_bytes: 256
bingo = [[int(j) for j in input().split()] for i in range(3)]
N = int(input())
for k in range(N):
  flag = 0
  hole = int(input())
  for i in range(3):
    for j in range(3):
      if bingo[i][j] == hole:
        bingo[i][j] = -1
        flag = 1
        break
    if flag == 1:
      break
        
if bingo[0][0] * bingo[0][1] * bingo[0][2] == -1:
  print("Yes")
elif bingo[1][0] * bingo[1][1] * bingo[1][2] == -1:
  print("Yes")
elif bingo[2][0] * bingo[2][1] * bingo[2][2] == -1:
  print("Yes")
elif bingo[0][0] * bingo[1][0] * bingo[2][0] == -1:
  print("Yes")
elif bingo[0][1] * bingo[1][1] * bingo[2][1] == -1:
  print("Yes")
elif bingo[0][2] * bingo[1][2] * bingo[2][2] == -1:
  print("Yes")
elif bingo[0][0] * bingo[1][1] * bingo[2][2] == -1:
  print("Yes")
elif bingo[0][2] * bingo[1][1] * bingo[2][0] == -1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
n,k=map(int,input().split())

x=[int(x) for x in input().rstrip().split()]


ans=float('inf')
for i in range(n-k+1):
  ans=min(abs(x[i])+abs(x[i+k-1]-x[i]),ans)
  ans=min(abs(x[i+k-1])+abs(x[i+k-1]-x[i]),ans)
  
print(ans)


Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define G           \
    if (++ip == ie) \
        if (fread(ip = buf, 1, SZ, stdin))
using namespace std;
const int SZ = 1 << 19, N = 1e5 + 9, M = 2 * N;
char buf[SZ], *ie = buf + SZ, *ip = ie - 1;
inline int in()
{
    G;
    while (*ip < '-')
        G;
    int x = *ip & 15;
    G;
    while (*ip > '-')
    {
        x *= 10;
        x += *ip & 15;
        G;
    }
    return x;
}
int h[N], w[M],o, q[M], f[N], c[N], v[N];
int Getf(int x)
{
    return x == f[x] ? x : f[x] = Getf(f[x]);
}
void Dfs(int x, int op)
{
    c[x] = op;
    for (int y, i = h[x]; i; i = w[i])
        if ((y = q[i]) != f[x])
            f[y] = x, Dfs(y, -op), c[x] += c[y];
}
int main()
{
    int n = in(), m = in(), qq = 1, ww = 1, ans = 0;
    for (int i = 1; i <= n; ++i)
        f[i] = i;
    for (int i = 1; i <= m; ++i)
    {
        int qw = in(), wq = in();
        if (Getf(qw) != Getf(wq))
            f[f[qw]] = f[wq];
        else
        {
            qq = qw;
             ww = wq;
            continue;
        }
        o++;
        w[o] = h[qw];
        q[o] = wq;
        h[qw]=o;
        o++;
        w[o] = h[wq];
        q[o] = qw;
        h[wq]=o;
    }
    f[qq] = 0;
    Dfs(qq, 1);
    if (n == m)
    {
        long long u=0;
        for (int i = ww; i; i = f[i]){
            u++;
            v[u] = c[i];
    }
        if (u % 2)
        {
            if (c[qq] % 2)
                return puts("-1"), 0;
            for (int i = ww; i; i = f[i])
                c[i] -= c[qq] / 2;
        }
        else
        {
            if (c[qq])
                return puts("-1"), 0;
            sort(v + 1, v + u + 1);
            for (int i = ww; i; i = f[i])
                c[i] -= v[u / 2];
        }
    }
    else if (c[qq])
        return puts("-1"), 0;
    for (int i = 1; i <= n; ++i)
        ans += abs(c[i]);
    return cout << ans, 0;
}

Measured memory_bytes: 14988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;


//dp[i]i払うときの最小回数
int dp[100001];

int main()
{
	int n;
	cin >> n;
	memset(dp,INF,100001*sizeof(int));
	dp[0]=0;
	rep(i,100001)
	{
		for(int j=1;j<6;j++)
		{
			if(i-j>=0)
			dp[i]=min(dp[i-j]+j,dp[i]);
		}
		for(int j = 6;j <= i ;j*=6)
		{
			dp[i] = min(dp[i],dp[i-j]+1);
		}
		for(int j = 9;j <= i ;j*=9)
		{
			dp[i] = min(dp[i],dp[i-j]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <vector>

using namespace std;

struct Node{
	Node(){
		brother = parent = -1;
		height = depth = num_of_children = 0;
	}
	int parent,brother,depth,num_of_children,height;
	vector<int> children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

void calcHeight(Node nodes[],int height,int parent){
	nodes[parent].height = max(nodes[parent].height,height+1);
	if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}

int main(){
	int n,id,left_id,right_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left_id,&right_id);
		if(left_id != -1){
			nodes[id].children.push_back(left_id);
			nodes[id].num_of_children++;
			nodes[left_id].parent = id;
		}
		if(right_id != -1){
			nodes[id].children.push_back(right_id);
			nodes[id].num_of_children++;
			nodes[right_id].parent = id;
		}
		if(left_id != -1 && right_id != -1){
			nodes[left_id].brother = right_id;
			nodes[right_id].brother = left_id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	if(n > 1){
		calcDepth(nodes,root_id);

		for(int i = 0; i < n; i++){
			if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
		}
	}

	for(int i = 0; i < n; i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
				,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
		if(nodes[i].parent == -1){
			printf(" root\n");
		}else if(nodes[i].num_of_children == 0){
			printf(" leaf\n");
		}else{
			printf(" internal node\n");
		}

	}
}


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

using namespace std;
typedef long long ll;




int main()
{
    
    
    string S;
    cin >> S;
    vector<string> A = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    
    rep(i,7){
        if(A[i] == S){
            cout << 7-i << endl;
        }
    }
    
    
    
    
    return 0;
}



Measured memory_bytes: 764
#include <queue>
#include <string>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include  <vector>
#define clr(a, b) memset(a, b, sizeof(a))
#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;

string s,t;

int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    cin >> s >> t;
    int len = s.length();
    int cot = 0;
    for (int i = 0; i < len; i++)
        if (s[i] != t[i]) ++cot;
    cout << cot;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

struct BiMatch{
  Int n;
  vector<vector<Int> > G;
  vector<Int> match,used;
  
  BiMatch(){}
  BiMatch(Int sz):n(sz),G(sz),match(sz),used(sz){}
  
  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<(Int)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 build(){
    Int res=0;
    fill(match.begin(),match.end(),-1);
    for(Int v=0;v<n;v++){
      if(match[v]<0){
	fill(used.begin(),used.end(),0);
	if(dfs(v)){
	  res++;
	}
      }
    }
    return res;
  }
};


Int isprime(Int x){
  if(x<=2) return 0;
  for(Int i=2;i*i<=x;i++)
    if(x%i==0) return 0;
  return 1;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
  
  vector<Int> a(1e7+100,0);
  for(Int i=0;i<n;i++) a[x[i]]=1;
  vector<Int> b;
  for(Int i=1;i<(Int)a.size();i++)
    if(a[i]^a[i-1]) b.emplace_back(i);

  Int m=b.size();
  BiMatch bm(m);
  for(Int i=0;i<m;i++)
    for(Int j=0;j<i;j++)
      if(isprime(b[i]-b[j]))
	bm.add_edge(i,j);

  Int k=bm.build();
  Int o=0,e=0;
  for(Int x:b) if(x&1) o++;else e++;
  //cout<<k<<" "<<o<<" "<<e<<endl;
  Int ans=k+((o-k)/2*2)+((e-k)/2*2)+((o-k)&1?3:0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i,n) for(int i=0;i<(int)(n);i++)
#define repd(i,n) for(int i=(int)(n);i>=0;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    int A,B;
    cin >> A >> B;
    cout << (A-1) * (B-1) << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 11-Jul-2020 18:02:48
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void INT(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void INT(T &x, W &y) {INT(x), INT(y);}
template <TN T, TN W, TN Q> inline void INT(T &x, W &y, Q &z) {INT(x, y), INT(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    int n; cin >> n;
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        int x; cin >> x;
        if ((x & 1) && (i & 1)) {
            ++res;
        }
    }

    cout << res << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // INT(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
n = gets.to_i

h = Hash.new(0)

n.times do |i|
  s = gets.chomp
  h[s[0]] += 1
end

march = "MARCH".chars
a =  Array.new(5){ |i| h[march[i]] }.select{|t| t > 0 }
# p a
ans = 0
a.combination(3).each{|t| ans += t.inject(:*) }

puts ans

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x=0;
  cin >> N;
  
		int a,b,c,d,e,f,g,h;
  
      	a=N/10000000;
      	b=(N-(a*10000000))/1000000;
      	c=(N-((10*a+b)*1000000))/100000;
      	d=(N-((100*a+10*b+c)*100000))/10000;
      	e=(N-((1000*a+100*b+10*c+d)*10000))/1000;
      	f=(N-((10000*a+1000*b+100*c+10*d+e)*1000))/100;
      	g=(N-((100000*a+10000*b+1000*c+100*d+10*e+f)*100))/10;
      	h=(N-((1000000*a+100000*b+10000*c+1000*d+100*e+10*f+g)*10))/1;        
      
      
  x=a+b+c+d+e+f+g+h;  

 
  if(N % x ==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
 }
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool N=0, W=0, S=0, E=0;
    for (char c:s) {
        N |= c=='N';
        W |= c=='W';
        S |= c=='S';
        E |= c=='E';
    }
    if (N!=S || W!=E) cout << "No\n";
    else cout << "Yes\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=100010;
int H,W,N,x[maxn],y[maxn];
map<pair<int,int>,bool>black;
long long ans[10];
int count(int a,int b){
	int ret=0;
	for(int i=a;i<=a+2;i++)
		for(int j=b;j<=b+2;j++)
			if(black[make_pair(i,j)])
				ret++;
	return ret;
}
int main(){
	//freopen("in","r",stdin);
	H=read(),W=read();
	N=read();
	for(int i=1;i<=N;i++){
		x[i]=read(),y[i]=read();
		black[make_pair(x[i],y[i])]=1;
	}
	for(int i=1;i<=N;i++)
		for(int j=x[i]-2;j<=x[i];j++)
			for(int k=y[i]-2;k<=y[i];k++)
				if(j>=1&&k>=1&&j+2<=H&&k+2<=W)
					ans[count(j,k)]++;
	for(int i=1;i<=9;i++)
		ans[i]/=i;
	ans[0]=1LL*(H-2)*(W-2);
	for(int i=1;i<=9;i++)
		ans[0]-=ans[i];
	for(int i=0;i<=9;i++)
		printf("%lld\n",ans[i]);
	return 0;
}



Measured memory_bytes: 157312
import java.util.*;
import java.math.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();
        BigDecimal a = new BigDecimal(input);
        BigDecimal b = new BigDecimal(0);
        BigDecimal answer = new BigDecimal(0);
        BigDecimal two = new BigDecimal(2);
      
      
      if(input==1){
        answer = a.divide(a);
      }else{
        b = a.divide(two,0, BigDecimal.ROUND_UP);
        answer = b.divide(a,10, BigDecimal.ROUND_DOWN);
      }
        System.out.println(answer);
    }
}

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

d = [True for i in range(n)] 

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        d[b-1] = False
    elif h[a-1] < h[b-1]:
        d[a-1] = False
    elif h[a-1] == h[b-1]:
        d[a-1] = False
        d[b-1] = False

print(d.count(True))

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    
    ll x; cin >> x;
    ll res = 1;
    ll now = x;
    while(1){
        if(now % 360 == 0)break;
        now += x;
        res++;
    }
    out(res);
}

Measured memory_bytes: 3648
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in A:
    if i % 2 == 0:
        count +=1
        if i % 5 == 0 or i % 3 == 0:
            count -=1
if count == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int k;string s;cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    cout<<s.substr(0,k)<<"..."<<endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int asc(const void *a, const void *b) {
  return *(char *)a - *(char *)b;
}
int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp( left_char, right_char );
}
int main(void){
		int N;
		long int ans(0),same(0);
		scanf("%d",&N);
		char mozi[N][11];
		rep(i,0,N){
			scanf("%s",mozi[i]);
			mozi[i][11] = '\0';
			qsort(mozi[i],10,sizeof(char),asc);
		}
		qsort(mozi,N,sizeof(mozi[0]),compare_char);
		rep(i,0,N - 1){
			same ++;
			if(strcmp(mozi[i],mozi[i + 1]) == 0) ans += same; else same = 0;
		}
		printf("%ld\n",ans);
	return 0;
}

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

using usize = ::std::size_t;
using u64 = ::std::uint_least64_t;

static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 N;

#define v(x, y, z) pow(x, 2)+pow(y, 2)+pow(z,2)+x*y+y*z+z*x

map<u64, u64> fac = {
    {0, 6}, {1, 3}, {3, 1}
};


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    vector<u64> cnt(10010, 0);
    
    for (u64 x = 1; x <= 100; x++) {
        for (u64 y = x; y <= 100; y++) {
            for (u64 z = y; z <= 100; z++) {
                if (v(x,y,z) > 10000) {
                    continue;
                }
                u64 overlapped = 0;
                overlapped += (u64)(x == y);
                overlapped += (u64)(y == z);
                overlapped += (u64)(x == z);
                cnt[v(x,y,z)] += fac[overlapped];
                //cout << x << " " << y << " " << z << endl;
            }
        }
    }
    
    
    for (u64 n = 1; n <= N; n++) {
        cout << cnt[n] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3688
import sys

def walk_preorder(n):
    c = children[n]
    print(' {}'.format(n), end='')
    if c[0]>=0: walk_preorder(c[0])
    if c[1]>=0: walk_preorder(c[1])

def walk_inorder(n):
    c = children[n]
    if c[0]>=0: walk_inorder(c[0])
    print(' {}'.format(n), end='')
    if c[1]>=0: walk_inorder(c[1])

def walk_postorder(n):
    c = children[n]
    if c[0]>=0: walk_postorder(c[0])
    if c[1]>=0: walk_postorder(c[1])
    print(' {}'.format(n), end='')
    

n = int(sys.stdin.readline())
parent = [-1 for _ in range(n)]
children = [[] for _ in range(n)]
for _ in range(n):
    id, left, right = list(map(int, sys.stdin.readline().split()))
    children[id] = [left, right]
    if left>=0:  parent[left] = id
    if right>=0: parent[right] = id

root=parent.index(-1)
order=[]
print('Preorder')
walk_preorder(root)
print()
print('Inorder')
walk_inorder(root)
print()
print('Postorder')
walk_postorder(root)
print()


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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 (a>b) { a=b; return true; } return false; }

const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll sum(ll l, ll r, int k){
    return ((l + r)*k) / 2;
}

int main(){
    int n, k;
    cin >> n >> k;
    mint ans = 0;
    for(int i = k; i <= n+1; i++){
        ll min_num = sum(0, i-1, i);
        ll max_num = sum(n-i+1, n, i);
        ans += (max_num - min_num + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
ll mod;
inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,m;
    cin>>n>>x>>m;
    vector<ll> rem;
    rem.pb(x%m);
    ll last=x;
    map<ll,ll> ma;
    ma[last]=0;
    ll pos=0;
    for(ll i=1;i<=m;i++){
        last=(last*last)%m;
        if(ma.find(last)!=ma.end()){
            pos=ma[last];
            break;
        }
        rem.pb(last);
        ma[last]=i;
    }
    vector<ll> rep(rem.begin()+pos,rem.end());
    ll siz=rep.size();
    ll ans=0;
    for(ll i=0;i<min(n,pos);i++){
        ans+=rem[i];
    }
    n=max(0ll,n-pos);
    ll sum=0;
    for(auto & x:rep){
        sum+=x;
    }
    ans+=sum*(n/siz);
    n%=siz;
    for(ll i=0;i<n;i++){
        ans+=rep[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7068
a, b, k = gets.chomp!.split(' ').map{|e| e.to_i}

result = []
k.times do |i|
    result << a+i if a+i >= a && a+i <= b
end

k.times do |i|
    result << b-i if b-i >= a && b-i <= b
end

result.uniq.sort.each{|e| puts e}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
using namespace std;vector<vector<int> >a(11,vector<int>(331));void r(int n,int u,int s,int d){a[n][s]++;for(int i=10;i-->0;)if(!(u>>i&1))r(n+1,u^1<<i,s+d*i,d+1);}main(){r(0,0,0,1);for(int n,s;cin>>n>>s;)cout<<a[n][s]<<endl;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    ll tmpa;
    vector<ll> a, res, res2;
    cin >> n;
    rep(i, n){
        cin >> tmpa;
        a.push_back(tmpa);
    }
    
    vsort(a);
    res.push_back(a[0]);
    res2.push_back(a[n-1]);

    int l=1, r=n-1, cnt=0;;
    while(l <= r){
        if(cnt%2 == 0){
            res.push_back(a[r--]);
            if(l > r) break;
            res.insert(res.begin(), a[r--]);
        }else{
            res.push_back(a[l++]);
            if(l > r) break;
            res.insert(res.begin(), a[l++]);
        }
        cnt++;
    }

    l=0, r=n-2, cnt=0;
    while(l <= r){
        if(cnt%2 == 1){
            res2.push_back(a[r--]);
            if(l > r) break;
            res2.insert(res2.begin(), a[r--]);
        }else{
            res2.push_back(a[l++]);
            if(l > r) break;
            res2.insert(res2.begin(), a[l++]);
        }
        cnt++;
    }

    //vdebug(res);

    ll answer = 0, answer2 = 0;
    rep(i, res.size()-1){
        answer += abs(res[i+1] - res[i]);
        answer2 += abs(res2[i+1] - res2[i]);
    }

    cout << max(answer, answer2) << endl;

    return 0;
}


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

const int N = 3003;
const int MOD = 998244353;

int n;

int solve() {
  char c;
  scanf("%c", &c);

  printf("%c\n", c >= 'A' && c <= 'Z' ? 'A' : 'a');
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include <fstream>

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int calcDist(int x, int y, int x2, int y2){
    return abs(x2-x) + abs(y2-y);
}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

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

    for(int i=1;i<n;i++){
        int max = 0;
        for(int j=0;j<i;j++){
            if(max < h[j]){
                max = h[j];
            }
        }

        if(h[i] >= max){
            ret++;
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    int count = 1;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == a[i-1]) {
            count++;
        } else {
            ans += count / 2;
            count = 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeu(int n){
		if(n<10)
			putchar(n+'0');
		else{
			writeu(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		if(readu()*readu()%2==1)
			puts("Yes");
		else
			puts("No");
	}
}
int main(){
	whatever::run();
}

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> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

ll x(ll x){
    ll res = 0;
    for(ll i=(x/4)*4;i<=x;i++) res ^= i;
    return res;
}

int main(){
    ll a,b;
    cin >> a >> b;
    if(a==0) cout << x(b) << endl;
    else cout << (x(a-1) ^ x(b)) << endl;
    return 0;
}

Measured memory_bytes: 3600