akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

const double EPS=1e-8;
const double PI=acos(-1);

double solve(const vector<double> &r){
	int n=r.size();
	vector<double> theta(n);

	double lo=0,hi=PI;
	rep(i,n-1){
		double a=(r[n-1]*r[0])/(r[i]*r[(i+1)%n]);
		if(a>1-EPS){
			lo=max(lo,acos( 1/a));
			hi=min(hi,acos(-1/a));
		}
	}
	rep(_,30){
		double mi=(lo+hi)/2;
		theta[n-1]=mi;
		rep(i,n-1){
			double a=(r[n-1]*r[0])/(r[i]*r[(i+1)%n]);
			theta[i]=acos(a*cos(theta[n-1]));
		}

		double sum=0;
		rep(i,n) sum+=theta[i];

		if(sum<2*PI) lo=mi; else hi=mi;
	}

	double area=0;
	rep(i,n) area+=r[i]*r[(i+1)%n]*sin(theta[i]);
	area/=2;
	return area;
}

int main(){
	int n; scanf("%d",&n);
	int r[8];
	rep(i,n) scanf("%d",r+i);

	double ans=0;
	rep(S,1<<n){
		vector<double> a;
		rep(i,n) if(S>>i&1) a.push_back(r[i]);
		if(a.size()<3) continue;

		sort(a.begin(),a.end());
		do{
			ans=max(ans,solve(a));
		}while(next_permutation(a.begin(),a.end()));
	}
	printf("%.9f\n",ans);

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a*b % 2 == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main() {
	int n,k,b[200010]={};
    // 配列の初期化
    for(int i=0;i<200010;i++){
        b[i] = 0;
    }    
	cin >> n >> k;
    //入力 + 初めて登場(?)した数があれば種類(cnt)をインクリメント
    int tmp;
    int cnt = 0;
	for(int i=0;i<n;i++){
		cin >> tmp;
        if(b[tmp] == 0){
            cnt++;
        }
        b[tmp]++;
	}
    // ボールの数が少ない順にソート
	sort(b,b+200010);
    // もともとK種類以下なら0を出力
	if(cnt<=k){
		cout << 0 << endl;
		return 0;
	}
	int sum=0;
    // cntがKになるまでb[i]の値をsumに足していく
    int j = 0;
	while(cnt > k){
        if(b[j] != 0){
            sum += b[j];
            cnt--;
        }
        j++;
    }
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>


using namespace std;


int main()
{
    int N;
    vector<int> T;
    int M;
    vector<int> P, X;

    cin >> N;

    for( int i = 0; i < N; ++i ){
        int t;
        cin >> t;
        T.push_back(t);
    }

    cin >> M;

    for( int i = 0; i < M; ++i ){
        int p, x;
        cin >> p >> x;
        P.push_back(p);
        X.push_back(x);
    }


    int all_time = 0;
    for( int i = 0; i < N; ++i ) all_time += T[i];


    for( int i = 0; i < M; ++i ) cout << all_time - T[P[i] - 1] + X[i] << endl;


    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> data(H);
	for (int i = 0; i < H; i++) cin >> data[i];
	for (int i = 0; i < H; i++) for (int k = 0; k < W; k++) if (data[i][k] == '.') {
		int hoge =0;
		for (int y = i-1; y <= i+1; y++) for (int x = k-1; x <= k+1; x++) {
			if (y >= 0 && y < H && x >= 0 && x < W && data[y][x] == '#') hoge++;
		}
		data[i][k] = hoge+'0';
	}
	for (int i = 0; i < H; i++) cout << data[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 using namespace  std;
int main(){
string s;
cin >> s;
int cflag = 0, fflag = 0;
for(auto x: s){
if(x=='C') cflag=1;
if(cflag==1 && x=='F') fflag=1;
}
if(fflag) cout<<"Yes";
else cout<<"No";
cout<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;

map<int,int> mp;

int main(){
    int n,k;
    int d,a;
    cin >> n >> k;
    for(int i=0;i<k;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            cin >> a;
            mp[a] ++;
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(mp[i+1] == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main {
	
	
	static void printa(int[] a,int n){
		for(int i=0;i<n-1;i++){
			System.out.printf("%d ",a[i]);
		}
		System.out.println(a[n-1]);
		return;
	}
	
	static void swap(int[] a,int x,int y){
		int temp=a[x];
		a[x]=a[y];
		a[y]=temp;
		return;
	}
	
	static int bubblesort(int[] a,int n){
		int cnt=0;
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n-i-1;j++){
				if(a[j] > a[j+1]){
					swap(a,j,j+1);
					cnt++;
				}
			}
		}
		
		return cnt;
	}
	
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		int n=scan.nextInt();
		int[] a=new int[n];
		
		for(int i=0;i<n;i++)
			a[i]=scan.nextInt();
		
		int cnt=bubblesort(a,n);
		
		printa(a,n);
		
		System.out.println(cnt);
		
	}
}


Measured memory_bytes: 26240
#include<iostream>
using namespace std;
int main() {
	int N,a,b,max=1,score=0;
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	while(N!=0){
		cin >> a >> b;
		if(a>=max) {
			max=a;
			score=b;
		}
		N--;
	}
	cout << max+score << "\n";
}

Measured memory_bytes: 892
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A+B+C <22){
    cout << "win" <<endl;
  }else{
    cout << "bust" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    /*mrep(i, k, n){
        ll rec = 1;
        ll nowrec = 1;
        mrep(j, i - k, i){
            rec *= a.at(j);
            nowrec *= a.at(j + 1);
        }
        if(nowrec > rec) cout << "Yes" << endl;
        else cout << "No" << endl;
    }*/
	
	mrep(i, k, n){
		if(a.at(i) > a.at(i - k)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
   	return 0;
}

Measured memory_bytes: 4044
#include<iostream>
int main(){
  long long a,b,c; std::cin >> a >> b >> c;
  if(((a + c - b) > 0 && c > a &&(a + c - b) * (a + c - b) > (4 * a  * c) )||
     ((a + b - c) > 0 && c > b &&(a + b - c) * (a + b - c) > (4 * a  * b)) ){
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        long N=sc.nextLong();
        
        if(N%2==1){
            System.out.println(0);
            return ;
        }

        N/=2;
        long i=5;
        long ans=0;
        
        for(i=5;i<=N;i*=5){
            ans+=N/i;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		int count = 0;
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(str[i]);

			if (k % 2 != 0) {
				count++;
			}
		}

		if (count % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x[100000],y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> n >> a >> b;
       rep(i,n){
           cin >> x[i];
       }
       rep(i,n-1){
           ans+=min((x[i+1]-x[i])*a,b);
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,m;
    cin >> n >> m;
    vector<LL> x(n);
    vector<LL> y(m);

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

    LL ysum = 0;

    for(int i = m-1; i >= 0; i--){
        ysum += y[i]*(m-1-i) - y[i]*i;
        ysum %= MOD;
    }

    LL sum = 0;

    for(int i = n-1; i >= 0;i--){
        //sum += ((((((x[i]*(n-1-i))%MOD)*m)%MOD)*(m-1))%MOD)*ysum;
        sum += ((x[i]*(n-1-i))%MOD)*ysum;
        sum %= MOD;
        //sum -= ((((((x[i]*i)%MOD)*m)%MOD)*(m-1))%MOD)*ysum;
        sum -= ((x[i]*i)%MOD)*ysum;
        sum %= MOD;
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n;
cin>>n;
if(n%1000==0)
cout<<0<<endl;
else
cout<<1000-n%1000<<endl;
	return 0;
}

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

using namespace std;

const int mod = 1'000'000'007;

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int inv(int a) {
  return pw(a, mod - 2);
}

const int N = 200'009;

int f[N];
int rf[N];

int choose(int n, int k) {
  return mul(f[n], mul(rf[k], rf[n - k]));
}

int main() {
  f[0] = 1;
  rf[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    rf[i] = inv(f[i]);
  }
  int n, a, b, c;
  scanf("%d%d%d%d", &n, &a, &b, &c);
  int co = mul(a + b + c, inv(100 - c));
  int pra = mul(a, inv(a + b));
  int prb = mul(b, inv(a + b));
  int ans = 0;
  for (int i = n; i <= 2 * n - 1; ++i) {
    add(ans, mul(mul(co, i), mul(choose(i - 1, n - 1), mul(pw(pra, n), pw(prb, i - n)))));
    add(ans, mul(mul(co, i), mul(choose(i - 1, n - 1), mul(pw(prb, n), pw(pra, i - n)))));
  }
  printf("%d\n", ans);
}


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

int main()
{
    ll N;
    cin >> N;
    for(ll h = 1; h <= 3500; ++h)
    {
        for(ll n = 1; n <= 3500; ++n)
        {
            ll big = N * h * n;
            ll smaller = (4 * h * n) - (N * (h + n));
            if(smaller > 0 && big % smaller == 0)
            {
                cout << h << ' ' << n << ' ' << big / smaller << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>

int main(){
  int n,q,i,j,left,right,mid,cnt=0;
  int S[100000];
  int T[50000];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  
  scanf("%d",&q);
  for(j=0;j<q;j++)
    scanf("%d",&T[j]);
  
  left=0;
  right=n;
  j=0;
  while(j!=q){
    mid=(left+right)/2;
    if(T[j]==S[mid]){
      cnt++;
      j++;
      left=0;
      right=n;
    }else if(T[j]>S[mid]){
      left=mid+1;
    }else if(T[j]<S[mid]){
      right=mid;
    }
    if(j!=q && left>=right){
      j++;
      left=0;
      right=n;
    }
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2324
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
//#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 300005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n;
int x[N], y[N];
Pair a[N];

signed main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(x[i], y[i]);
		if (x[i] > y[i]) swap(x[i], y[i]);
		a[i] = make_pair(x[i], y[i]);
	}

	long long ans = inf;
	int minx = inf, maxx = 0, miny = inf, maxy = 0;

	for (int i = 1; i <= n; ++i) {
		chkmin(minx, x[i]);
		chkmax(maxx, x[i]);
		chkmin(miny, y[i]);
		chkmax(maxy, y[i]);
	}

	chkmin(ans, 1ll * (maxx - minx) * (maxy - miny));

	sort(a + 1, a + n + 1);
	long long D = maxy - minx;

	minx = inf;
	for (int i = 1; i <= n; ++i) {
		chkmax(maxx, a[i].se);
		chkmin(minx, a[i].se);
		if (a[i + 1].fi >= minx) {
			chkmin(ans, D * (maxx - minx));
			break;
		}
		chkmin(ans, D * (maxx - a[i + 1].fi));
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

struct Info{
	Info(){
		node_id = pre_node = sum_value = 0;
	}

	Info(int arg_node_id,int arg_pre_node,int arg_sum_value){
		node_id = arg_node_id;
		pre_node = arg_pre_node;
		sum_value = arg_sum_value;
	}
	bool operator<(const struct Info &arg) const{ //★総価値の降順(PQ)★
		return sum_value < arg.sum_value;
	}

	int node_id,pre_node,sum_value;
};

int N,M;
int root;
int value[NUM],in_num[NUM],max_value[NUM];
bool is_cicle[NUM];
vector<int> G[NUM];

/*
 * 木なら葉がある→入次数が1のノードがある!!
 * 葉を刈ったら葉になるノードは、木の一部で非サイクル経路
 */


int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++)scanf("%d",&value[i]);

	for(int i = 0; i < N; i++)in_num[i] = 0;

	root = 0;
	int from,to;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		G[from].push_back(to);
		G[to].push_back(from);
		in_num[from]++;
		in_num[to]++;
	}

	for(int i = 0; i < N; i++)is_cicle[i] = true;

	//非サイクル部分を計算
	queue<int> CALC;
	for(int i = 1; i < N; i++){
		if(in_num[i] == 1){
			is_cicle[i] = false;
			CALC.push(i);
		}
	}

	int node_id;
	int next_node,next_value;

	while(!CALC.empty()){
		node_id = CALC.front();
		CALC.pop();

		for(int i = 0; i < G[node_id].size(); i++){
			next_node = G[node_id][i];
			if(is_cicle[next_node] == false || next_node == root)continue; //既に葉と認定されているならSKIP

			in_num[next_node]--;
			if(in_num[next_node] == 1){ //ボトムアップ的（再帰的）に、木の経路上にあるノードを特定する
				is_cicle[next_node] = false;
				CALC.push(next_node);
			}
		}
	}

	int ans = value[root];
	for(int i = 1; i < N; i++){
		if(is_cicle[i]){ //サイクル経路上のノードなら、全て訪問可能
			ans += value[i];
		}
	}

	int maximum = 0;
	for(int i = 0; i < N; i++)max_value[i] = 0; //★★木上の頂点は、元来たノードに戻れないとの制約のため、事実上の有向路となるので、到達時の最大コストで切る★★

	//始点(rootから行き来できるサイクル中のどれか)をPQに突っ込む
	priority_queue<Info> Q;
	for(int i = 0; i < N; i++){
		if(!is_cicle[i])continue; //サイクル上の点でなければSKIP

		for(int k = 0; k < G[i].size(); k++){
			next_node = G[i][k];
			if(is_cicle[next_node])continue; //行先がサイクル上の点ならSKIP

			next_value = value[next_node];
			if(max_value[next_node] < next_value){ //最大値で遷移する場合のみpush
				max_value[next_node] = next_value;
				Q.push(Info(next_node,i,next_value));
			}
		}
	}

	Info info;
	while(!Q.empty()){

		//★★降順かつ、値の増えるループなので、先にpopしておく★★
		info = Q.top();
		Q.pop();

		maximum = max(maximum,info.sum_value);

		if(info.sum_value < max_value[info.node_id]){
			continue;
		}else{
			for(int i = 0; i < G[info.node_id].size(); i++){
				next_node = G[info.node_id][i];
				if(next_node == info.pre_node || is_cicle[next_node] == true)continue;
				next_value = info.sum_value+value[next_node];

				if(max_value[next_node] < next_value){
					max_value[next_node] = next_value;
					Q.push(Info(next_node,info.node_id,next_value));
				}
			}
		}
	}

	printf("%d\n",ans+maximum);

	return 0;
}



Measured memory_bytes: 12168
class Node:
    def __init__(self):
        self.key = -1
        self.p = -1
        self.l = -1
        self.r = -1

def insert(k):
    y = -1
    x = root[0]
    z = len(T)
    T.append(Node())
    T[z].key = k
    while x != -1:
        y = x
        if T[z].key < T[x].key: x = T[x].l
        else: x = T[x].r
    T[z].p = y
    if y == -1: root[0] = z
    elif T[z].key < T[y].key: T[y].l = z
    else: T[y].r = z

def find(k):
    x = root[0]
    while x != -1 and T[x].key != k:
        if k < T[x].key: x = T[x].l
        else: x = T[x].r
    return x

def delete(z):
    if T[z].l == -1 or T[z].r == -1: y = z
    else: y = getSuccessor(z)
    if T[y].l != -1: x = T[y].l
    else: x = T[y].r
    if x != -1: T[x].p = T[y].p
    if T[y].p == -1: root[0] = x
    elif y == T[T[y].p].l: T[T[y].p].l = x
    else: T[T[y].p].r = x
    if y != z: T[z].key = T[y].key

def getSuccessor(x):
    if T[x].r != -1: return getMinimum(T[x].r)
    y = T[x].p 
    while y != -1 and x == T[y].r:
        x = y
        y = T[y].p
    return y

def getMinimum(x):
    while T[x].l != -1: x = T[x].l
    return x

def inorder(u):
    if u == -1: return
    inorder(T[u].l)
    print(" {}".format(T[u].key),end="")
    inorder(T[u].r)

def preorder(u):
    if u == -1: return
    print(" {}".format(T[u].key),end="")
    preorder(T[u].l)
    preorder(T[u].r)

m = int(input())
T = []
root = [-1]
lst = [input().split() for _ in range(m)]
for i in range(m):
    comm = lst[i][0]
    if len(lst[i]) == 2: key = int(lst[i][1])
    if comm == "insert":
        insert(key)
    elif comm == "find":
        print("yes" if find(key) != -1 else "no")
    elif comm == "delete":
        delete(find(key))
    else:
        inorder(root[0])
        print("")
        preorder(root[0])
        print("")


Measured memory_bytes: 242180
/* be name khoda */
#include <bits/stdc++.h>
using namespace std;

typedef int ll;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, n) forifrom(i, 0, n)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define forir(i, n) forirto(i, n, 0)

typedef pair<ll, ll> pii;

#define eb emplace_back
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

// ------------------------------------------------------------------

const ll maxn = 100010;

ll n, A[maxn];

// 0 -> First Lose, 1 -> First Win
ll solve() {
    ll s = 0, o = -1; // we have at least one odd number (gcd = 1)
    fori (i, n) {
        s += A[i] - 1;
        if (A[i] % 2) {
            if (o == -1) o = i;
            else o = n;
        }
    }
    if (s % 2) return 1;
    else if (o == n || A[o] == 1) return 0;
    else {
        --A[o];
        ll g = 0;
        fori (i, n) g = __gcd(g, A[i]);
        fori (i, n) A[i] /= g;
        return 1 ^ solve();
    }
}

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

    cin >> n;
    fori (i, n) cin >> A[i];
    ll r = solve();
    cout << (r ? "First\n" : "Second\n");

}


Measured memory_bytes: 4032
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    int r=0,b=0;
    Cini(N);
    Cins(S);
    rep(i,N){
        if(S[i]=='B') b++;
        if(S[i]=='R') r++;
    }
    if(r>b) cout << "Yes" <<nn;
    else cout << "No" << nn;
    return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	double l;
	cin >> l;

	double one = l/3.0;
	double ans = pow(one,3);

	printf("%.10f", ans);




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[10000];
int n;
double ans=0;
double cnt(){
	double las=a[1];
	for(int i=2;i<=n;i++){
		las=(a[i]+las)/2;
	}
	return las;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	ans=cnt();
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int a, b;
int ans = 0;
/**********************************************/
bool kaibun(int a){
    string s = to_string(a);
    REP(i, s.size()/2){
        if(s[i] != s[s.size()-1-i]) return false;
    }
    return true;
}

signed main(){
    cin >> a >> b;

    FOR(i, a, b+1){
        if(kaibun(i)) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=305;
int n,m,t,i,j,mx,ans,a[N][N],cs[N],cnt[N];
int main()
{
//	freopen("sf.in","r",stdin);
//	freopen("sf.out","w",stdout);
	scanf("%d%d",&n,&m);
	rep(i,1,n)
		rep(j,1,m) scanf("%d",&a[i][j]);
	rep(i,1,m) cs[i]=1;
	ans=n+1;
	rep(t,1,m)
	{
		rep(i,1,m) cnt[i]=0;
		rep(i,1,n)
		{
			rep(j,1,m) if (cs[a[i][j]]) break;
			cnt[a[i][j]]++;
		}
		mx=0;
		rep(i,1,m)
			if (cnt[i]>cnt[mx]) mx=i;
		ans=min(ans,cnt[mx]);
		cs[mx]=0;
	} 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main(int argc, const char * argv[]) {
    int a[5];
    for(int i=0;i<5;i++){
        scanf("%d",&a[i]);
        if(a[i]==0){
            printf("%d",i+1);
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 1676
#働く日は左から順に貪欲にとると、前に詰める感じで最も効率が良い
#ベストな時、何日目に何回の勤労が始まったかを取れるため、i回目の勤労はL[i]日目以降になりうる、という配列Lをとれる
#一方右から貪欲にとると、何が起きるか
#一番右のoは最終日に働き、間隔を開け次のoを次の日に…というようにすると、
#これは後ろから詰める感じで効率が良いことがわかる
#よってi回目の労働はR[i]日目以前になりうる、という配列Rを取れる
#ここで、L,Rの構成可能性は約束されているので(やさしい)
#x回目の労働がL[i]日目以降R[i]日目以前という意味より、L[x]=R[x]の時はx回目の勤労はL[x]=R[x]日目にやらないといけないことを意味する
#(逆説的にL[x]!=R[x]ならばi回目は必ず違う勤労日を構成できることを意味する)
from collections import deque
N,K,C=map(int,input().split())
S=list(input())
L=deque()
l=[]
R=deque()
r=[]
i=0
while len(L)<K:
    if S[i]=="o":
        L.append(i)
        i=i+(C+1)
    else:
        i=i+1
i=N-1
while len(R)<K:
    if S[i]=="o":
        R.appendleft(i)
        i=i-(C+1)
    else:
        i=i-1
l=list(L)
r=list(R)
#print(l,r)
for i in range(K):
    if l[i]==r[i]:
        print(l[i]+1)


Measured memory_bytes: 68424
#include<stdio.h>
#define MAX 500000
#define NIL -1
//#define SWAP(a,b) {typeof(a) temp = a; a = b; b = temp; }
typedef struct node{
  int leftid;//親がもっている左側のid
  int rightid;//親がもっている右側のid
  int left;//親がもっている左側のkey
  int right;//親がもっている右側のkey
  int key;//自身のkey
  int p;//自身の親のkey

}Node;
void SWAP(int,int);
void maxHeapify(int,int);
void buildMHeap(int);
Node node[MAX+1];
int main(){
  int n,i,num,l,tmp;
  scanf("%d",&n);
  //初期化
  for(i=1;i<=n;i++){
    node[i].left=NIL;
    node[i].right=NIL;
    node[i].leftid=NIL;
    node[i].rightid=NIL;
    node[i].key=NIL;
    node[i].p=NIL;

  }
  for(i=1;i<=n;i++){
    //入力の個数の入力
    scanf("%d",&num);
    //根のときの処理
    if(i==1){
      node[i].key=num;
      tmp=i;
   
    }
    //自身から見たときに左側になにも値が入ってないときに行う処理
   else if(node[tmp].leftid==NIL){
     node[i].key=num;
     node[tmp].left=num;
     node[tmp].leftid=i;
     node[i].p=node[i/2].key;//ヒープなのでid自身のidを半分にすると親のidになるのでそのときのkeyを代入している
    
    }
     //自身から見たときに右側になにも値が入ってないときに行う処理
   else if(node[tmp].rightid==NIL){
     node[i].key=num;
     node[tmp].right=num;
     node[tmp].rightid=i;
     node[i].p=node[i/2].key;//ヒープなのでid自身のidを半分にすると親のidになるのでそのときのkeyを代入している
     tmp++;
   }
  }
  
  buildMHeap(i-1);
  for(i=1;i<=n;i++){
    if(i!=n){
    printf(" %d",node[i].key);
    }
    else{
 printf(" %d\n",node[i].key);
    }
  }
 
  return 0;
}
void maxHeapify(int i,int H){
  int l=node[i].leftid;
  int r=node[i].rightid;
  int largest;
  if(l<=H && node[l].key>node[i].key&&l!=-1){
    largest=l;
  }
  else{
    largest=i;
  }
  if(r<=H && node[r].key>node[largest].key&&r!=-1){
    largest=r;
  }
  if(largest!=i){
    
    
    SWAP(i,largest);
   
    maxHeapify(largest,H);
  }
}
void buildMHeap(int H){
  int i;
  for(i=H/2;i>=1;--i){
    maxHeapify(i,H);
  }

}
void SWAP (int p,int q){
  int tmp;
  tmp=node[p].key;
  node[p].key=node[q].key;
  node[q].key=tmp;
}









Measured memory_bytes: 13396
#include"bits/stdc++.h"
using namespace std;
int n;
const int mod=1000000000+7;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    while(cin >> n){
        long long int ans=1;
        for(int i=1;i<=n;i++){
            ans=ans*i%mod;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

if __name__ == '__main__':

    while True:
        s = input()
        if s == '.':
            break
        s2 = ''
        for i in s:
            if i == '(' or i == ')' or i == '[' or i == ']':
                s2 += i
        cnt = 0
        while cnt <= 50:
            s2 = s2.replace('()', '')
            s2 = s2.replace('[]', '')
            cnt += 1
        if len(s2) != 0:
            print('no')
        else:
            print('yes')

Measured memory_bytes: 7388
#include <iostream>

using namespace std;

int harshad(int n)  {
    int res = 0;
    while (n > 0)   {
        res += n % 10;
        n /= 10;
    }
    return res;
}

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

Measured memory_bytes: 3596
while True:
	try:
		a,b,c = map(str, raw_input().replace("+","=").split("="))
		i = 1 if a!=a[0]=="X" or b!=b[0]=="X" or c!=c[0]=="X" else 0
		for x in range(i,10):
			if eval((a+"+"+b).replace("X",str(x))) == int(c.replace("X",str(x))):
				print x
				break
		else:
			print "NA"
	except:
		break

Measured memory_bytes: 4256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) \
    sort(all((x)));    \
    (x).resize(unique(all((x))) - (x).begin())
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | ";
    __f(comma + 1, args...);
}

ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
void yes_or_no(ll x)
{
    if (x)
        cout << "YES\n";
    else
        cout << "NO\n";
}
void solve_test()
{
    ll ans = 0;
    ll n;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ans = (a * c);
    ans = max(ans, (a * d));
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans << "\n";
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    // cin >> t; while (t--)
    solve_test();
    return 0;
}


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

int main() {
    int h,w;
    char ch[50][50];
    int a[60][60];
  
    for(int i = 0; i < 60; i++){
     for(int j = 0; j < 60; j++){
          a[i][j] = 0;
        }
      }
    
    cin >> h >> w;
    for (int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
      cin >> ch[i][j];
      }
    }
  
    for(int i = 0; i < w; i++){
      for(int j = 0; j < w; j++){
        if(ch[i][j] == '#'){
          a[i+1][j+1] = 1;
        }else{
          a[i+1][j+1] = 0;
        }
      }
      }
      
    for(int i = 1; i < h -1;i++){
       for(int j = 1;j < w - 1;j++){
         if(a[i][j] == 1 && a[i - 1][j] + a[i + 1][j] + a[i][j - 1] + a[i][ j+ 1 ] == 0){
            cout << "No" << endl;
            return 0;
         } else{
         }         
       }
     }
    
    cout << "Yes" << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    vector <int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= (i+1);
    }

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

    int cho = A.size()%2 == 0 ? (A[A.size()/2] + A[A.size()/2-1])/2 : A[A.size()/2];
    long long sum = 0;
    long long sum2 = 0;

    for (int i = 0; i < N; ++i) {
        sum += abs(cho - A[i]);
    }

    for (int i = 0; i < N; ++i) {
        sum2 += abs(cho+1 - A[i]);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    string S;
    cin>>S;
    int A[26]={0};
    for(int i=0;i<S.length();i++){
        A[S[i]-97]++;
    }
    for(int i=0;i<26;i++){
        if(A[i]==0){
            cout<<char('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,s[1000],ans=0,t;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&s[i]),ans+=s[i];
    if(ans%10)
    {
        printf("%d\n",ans);
        return 0;
    }
    sort(s+1,s+n+1);t=ans;
    for(int i=1;i<=n;i++)
    {
        if(s[i]%10)
        {
            ans-=s[i];break;
        }
    }
    if(ans==t)ans=0;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
bool used[2*100005];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N, x;
    cin >> N >> x;
    vector<int> ans(2 * N - 1);
    if(x==1 || x== 2*N -1){
        cout << "No" << endl;
        return 0;
    }
    if(x==2&&N==2){
        cout << "Yes" << endl;
        cout << 1 << " " << 2 << " " << 3 << endl;
        return 0;
    }
    cout << "Yes" << endl;
    int mid = ans.size() / 2;
    if(x<2*N-2){
        ans[mid] = x;
        used[x] = 1;
        ans[mid + 1] = x + 1;
        used[x+1] = 1;
        ans[mid - 1] = x - 1;
        used[x-1] = 1;
        ans[mid - 2] = x + 2;
        used[x+2] = 1;
        int cnt = 1;
        rep(i,2*N-1){
            if(ans[i]==0){
                while(used[cnt]==1)cnt++;
                ans[i] = cnt;
                cnt++;
            }
        }
    }else if(x=2*N-2){
        ans[mid] = x;
        ans[mid-1] = x+1;
        ans[mid+1] = x-2;
        ans[mid-2] = x-1;
        int cnt = 1;
        rep(i,2*N-1){
            if(ans[i]==0){
                while(used[cnt]==1)cnt++;
                ans[i] = cnt;
                cnt++;
            }
        }
    }
    for(auto x:ans)cout << x << endl;
}

Measured memory_bytes: 2304
N, K = map(int, input().split())
mod = 10**9 + 7

gcd = {}
s = 0

for x in range(K,0,-1):
  
    i = K // x
    tmp = pow(i,N,mod)  # 組み合わせ数
    
    if i > 1:
        for j in range(2,i+1):
            tmp -= gcd[j * x]
    
    gcd[x] = tmp
    s += (tmp * x) % mod
    s %= mod

print(s)

Measured memory_bytes: 20764
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")

#include<bits/stdc++.h>

#define pb push_back
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f(i, a ,b) for(int i = (int)a; i <=(int)(b);i++)
#define int long long
#define endl "\n"
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;

using namespace std;

const int N = 1e5+5,MOD = 1000000007, INF = 0xFFFFFFFFFFFFFFFL;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void IOS()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
   	cout.precision(10);
   	cout << fixed;
}
int a[N],dp[N];
	
int32_t main()
{
	IOS();
	int n;
	cin >> n;
	for(int i = 0 ; i < n; i++)
	{
		cin >> a[i];
	}			
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for(int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
	}
	cout << dp[n-1];
	return 0;
}

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

using ll = long long;

int main() {
	ios :: sync_with_stdio(0);
	ll n, x; cin >> n >> x;
	ll ans = 0;
	while(1) {
		//cout << n << ' ' << x << '\n';

		if(x * 2 < n) {
			ans += x + n; x = n - x; n = n - x;
		} else {
			ans += x; x = n - x; n = n - x;
			ans += n / x * x * 2; n %= x;
			if(n != 0) ans += x + n;
		}
		if(n == 0) break;
		swap(n, x); x = n - x; ans -= x;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using  INT = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*........................................DEFINE FUNCTIONS.........................................*/
struct UnionFind {
	vector<int> d; //iが子ならd[i]は親のidでiが親ならd[i]は -サイズ
	UnionFind(int n): d(n, -1) {}
	int find(int x) {
		if (d.at(x) < 0)return x;//親なら自分自身の番号を返す
		else return d.at(x) = find(d.at(x)); //経路圧縮　メモ化
	}
	bool unite(int x, int y) { //voidでもいいが、くっつけられるか判定できた方が嬉しいときもある
		x = find(x); y = find(y); //根同士をくっつけるため
		if (x == y) return false;//統合できない(しない)
		if (-d.at(x) < -d.at(y)) swap(x, y);
		d.at(x)+= d.at(y); //親のサイズの更新 サイズが大きい方に小さい方を統合
		d.at(y) = x;//yは親ではなくなったのでyの親をｘに設定
		return true;//統合できた
	}
	int size(int x) {return -d.at(find(x));}
	bool same(int x, int y) {return find(x) == find(y);}
};

/*....................................DEFINE GLOBAL VARIABLES .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, M, K;
	cin>>N>>M>>K;
	UnionFind uf(N);

	Graph AB(N), CD(N);
	REP(i, M) {
		int a, b;
		cin >> a >> b; a--; b--;
		uf.unite(a,b);

		AB.at(a).push_back(b);
		AB.at(b).push_back(a);
	}
	REP(i, K) {
		int c, d;
		cin >> c >> d; c--; d--;
		CD.at(c).push_back(d);
		CD.at(d).push_back(c);
	}

	REP(i,N){
		int num=uf.size(i);
		num-=(AB.at(i).size() + 1 );//直の友達と自分を引く
		for(auto b:CD.at(i)){
			if(uf.same(i,b))num--;
		}
		cout<<num<<" ";
	}
	cout<<endl;



	return 0;
}







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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;
        int h,n;
        cin>>h>>n;
        vector<pair<int,int>> v;
        for(int i=0;i<n;i++)
        {
            int x,y;
            cin>>x>>y;
            v.pb({x,y}); 
        }
        
        int dp[100005];
           dp[0]=0;
        for(int i=1;i<=h;i++)
        {    dp[i]=INT_MAX;
            for(int j=0;j<n;j++)
            {
                dp[i]=min(dp[i],(dp[max(0,i-v[j].ff)]+v[j].ss));
            }
        }
        cout<<dp[h]<<endl;

    }

Measured memory_bytes: 384
#include <iostream>

using namespace std;

void printRectangle(int height, int width) {
    for (int row = 0; row < height; ++row) {
        string line;
        bool isTopBottom = (row == 0 || row == height - 1) ? true : false;
        for (int column = 0; column < width; ++column) {
            bool isLeftRightEnd = (column == 0 || column == width - 1) ? true : false;
            line += (isTopBottom || isLeftRightEnd) ? "#" : ".";
        }

        cout << line << endl;
    }

    cout << endl;
}

int main() {
    while (true) {
        int height, width;
        cin >> height >> width;

        if (height == 0 && width == 0) break;

        printRectangle(height, width);
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int64_t ans = 0;
  
  for (int i=0;i < N; i++) {
    if (!((i+1) % 3 == 0  || (i+1) % 5 == 0  )) {
      ans += (i+1);
    }
  }
    cout << ans << endl;
  }


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == 5 && b == 5 && c == 7)
  {
    cout << "YES";
  }
  else if(a == 5 && b == 7 && c == 5)
  {
    cout << "YES";
  }
  else if(a == 7 && b == 5 && c == 5)
  {
    cout << "YES";
  }
  else
  {
    cout << "NO";
  }
}

Measured memory_bytes: 256
import java.io.*;

/**
 * Created by Ayushi on 15/09/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] in = r.readLine().split("");
        int n = in.length;
        r.close();

        boolean ans = true;
        for (int i = 0; i < n && ans; i++) {
            if ((i % 2 == 0 && in[i].equals("L")) || (i % 2 == 1 && in[i].equals("R"))) {
                ans = false;
                //System.out.println("i+1 = " + (i+1));
                //System.out.println("in[i] = " + in[i]);
            }
        }

        System.out.println(ans? "Yes":"No");
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    string c;cin>>c;
    string s={"aiueo"};
    bool flag=false;
    rep(i,5){
        if(c[0]==s[i])flag=true;
    }
    if(flag)cout<<"vowel";
    else cout<<"consonant";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        float x = sc.nextFloat();
        float y = sc.nextFloat();

        float b = (y-2*x) / 2;
        float a = (x-b);

        if(b>=0 && b==(int)b) {

        } else {
            System.out.print("No");
            return;
        }

        if(a>=0 && a==(int)a) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
        return;
    }
}

Measured memory_bytes: 37336
#include<stdio.h>
#include<math.h>

int main(void){
  int N, X, T;

  scanf("%d %d %d", &N, &X, &T);
  if(N==0){
    printf("0");
  } else if( (N%X )==0){
    printf("%d", (N/X)*T);
  }
  else{
    printf("%d", (N/X+1)*T);
  }
  return 0;
}

Measured memory_bytes: 1732
def main(): # A162
    N = int(input())
    NUM = list(str(N))
    NUM = list(map(int,NUM))
    #A = list(map(int, input().split()))  # [1,2,3,4,5]
    for i in NUM:
        if int(i) == 7:
            print("Yes")
            exit(0)
    print("No")
    
main()

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,string> P;

vector<string> split(const string &s, char d)
{
    vector<string> ret;
    stringstream ss(s);
    string buf;
    while(getline(ss,buf,d)) ret.pb(buf);
    return ret;
}

int main()
{
    int n;
    while(cin >>n,n)
    {
        cin.ignore();

        vector<string> s(n);
        rep(i,n)
        {
            getline(cin,s[i]);
        }

        map<string,int> m;
        rep(i,n)
        {
            vector<string> v=split(s[i],' ');
            rep(j,v.size())
            {
                if(m.find(v[j])==m.end()) m[v[j]]=1;
                else ++m[v[j]];
            }
        }

        vector<P> ans;

        char head;
        scanf(" %c", &head);
        for(const auto &x : m)
        {
            if(x.fi[0]==head) ans.pb(P(-x.se,x.fi));
        }

        sort(all(ans));

        if(ans.size()==0) printf("NA\n");
        else
        {
            rep(i,min(5,(int)ans.size()))
            {
                if(i) printf(" ");
                cout << ans[i].se;
            }
            cout << endl;
        }

    }
    return 0;
}

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

int findSumOfDigits6(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 6;
    n /= 6;
  }
  return sum;
}
int findSumOfDigits9(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 9;
    n /= 9;
  }
  return sum;
}
int main() {
  int N;
  cin >> N;
  int kaisuu = N;
  for (int i = 0; i <= N; ++i) 
  {
    int x = findSumOfDigits6(i);
    int y = findSumOfDigits9(N-i);
    int s = x + y; 
    kaisuu = min(kaisuu, s); 
    }
  cout << kaisuu << endl;
}


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll N; cin >> N;
	vector<ll> A(5);
	for (ll& a : A) cin >> a;
	ll mi = *min_element(A.begin(), A.end());
	ll ans = 4 + ((N + mi - 1) / mi);
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<int,ll> p;
typedef pair<pii,int> P;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll f(ll a,ll b){
    if(b==0) return -a;
    return 2*(a/b)*b+f(b,a%b);
}
int extgcd(int a,int b,int &x,int &y){
    if(b==0){
        x=1,y=0;
        return a;
    }
    int d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
    return d;
}
int main(){
    int a,b;cin>>a>>b;
    int x,y;
    extgcd(a,b,x,y);
    cout<<x<<' '<<y<<endl;
    return 0;
}


Measured memory_bytes: 3128