akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int h,w;
char a[514][514],r[514][514],b[514][514];
signed main() {
	scanf("%lld %lld",&h,&w);
	rep(i,h) {
		rep(j,w) {
			cin>>a[i][j];
		//	scanf("%c",&a[i][j]);
			r[i][j]='.';
			b[i][j]='.';
		}
	}
	rep(i,h) {
		r[i][0]='#';
		b[i][w-1]='#';
	}
	rep(i,h) {
		if(i&1) {
			for(int j=1;j<w-1;j++) r[i][j]='#';
		}
		else {
			for(int j=1;j<w-1;j++) b[i][j]='#';
		}
	}
	rep(i,h) {
		rep(j,w) {
			if(a[i][j]=='#') {
				r[i][j]=b[i][j]='#';
			}
		}
	}
	rep(i,h) {
		rep(j,w) {
			printf("%c",r[i][j]);
		}
		cend;
	}
	cend;
	rep(i,h) {
		rep(j,w) {
			printf("%c",b[i][j]);
		}
		cend;
	}
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
#include <chrono>
#include <tuple>
#include <string>
#include <random>
#include <cstdio>
#define ll long long int
// #define endl '\n'
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
const int N = 100001;
vector<int> adj[N];
ll mod = 1000000007;

void solve() 
{
    int n;
    cin>>n;

    vector<pair<int, int> > v(n);
    rep(i, n)
    {
        int a, b;
        cin>>a>>b;

        v[i] = mp(a, b);
    }

    // int flag = 0;
    rep(i, n - 2)
    {
        if(v[i].F == v[i].S && v[i+1].F == v[i+1].S && v[i+2].F == v[i+2].S)
        {
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 6168
N=int(input())
list=[1]
i=1
while(6**i<=N):
    list.append(6**i)
    i+=1
i=1
while(9**i<=N):
    list.append(9**i)
    i+=1
list.sort(reverse=True)
n=len(list)
INF=10**19
dp=[INF]*(N+1)
dp[0]=0
for i in range(N):
    for j in list:
        if i+1-j>=0:
            dp[i+1]=min(dp[i+1],dp[i+1-j]+1)
print(dp[N])


Measured memory_bytes: 42716
#include<iostream>
using namespace std;
int main(){
	int n,k,p,win;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k>>p;
		if(k%p==0){
			cout<<p<<endl;
		}else{
			cout<<k%p<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n,k,ans=0;cin>>n>>k;
    vi A(n);cin>>A;

    for(int i=0;i<n;i++){
        int piche=0,aage=0;
        for(int j=0;j<i;j++){
            if(A[j]<A[i]){
                piche++;
            }
        }
        for(int j=i+1;j<n;j++){
            if(A[j]<A[i]){
                aage++;
            }
        }
        //cout<<piche<<" "<<aage<<"\n";
        int inv2=(MOD+1)/2;
        int aaa=(aage*((k*(((k+1)*inv2)%MOD))%MOD))%MOD;
        int bbb=( (k*((piche*(((k+1)*inv2)%MOD))%MOD))%MOD -(k*piche)%MOD+MOD)%MOD;
        ans=(ans+aaa+bbb)%MOD;
    }

    cout<<ans;

}


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

typedef double D;
typedef complex<D> P;

D cross(P x, P y){return imag(conj(x)*y);}

bool triContain(P a, P b, P c, P p){
    P ab = b - a;
    P ap = p - a;
    P bc = c - b;
    P bp = p - b;
    P ca = a - c;
    P cp = p - c;
    if(cross(ab, ap) > 0 && cross(bc, bp) > 0 && cross(ca, cp) > 0)return true;
    if(cross(ab, ap) < 0 && cross(bc, bp) < 0 && cross(ca, cp) < 0)return true;
    return false;
}

int main(){

   D ax, ay, bx, by, cx, cy, px, py;
   while(cin>>ax>>ay>>bx>>by>>cx>>cy>>px>>py){
       P a(ax, ay), b(bx, by), c(cx, cy), p(px, py);
       if(triContain(a, b, c, p))cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
   }

    return 0;
}


Measured memory_bytes: 3152
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static int ans = Integer.MAX_VALUE;
	static int C;
	static int[][] d;
	static ArrayList<Integer> zero;
	static ArrayList<Integer> one;
	static ArrayList<Integer> two;
	static int[][]memo;




	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		C = sc.nextInt();
		d = new int[C][C];
		for(int i = 0;i < C;i++){
			for(int j = 0;j < C;j++){
				d[i][j] = sc.nextInt();
			}
		}
		int[][] c = new int[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				c[i][j] = sc.nextInt()-1;
			}
		}	
		zero = new ArrayList<Integer>();
		one = new ArrayList<Integer>();
		two = new ArrayList<Integer>();

		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				if((i + 1 + j + 1)%3 == 0){
					zero.add(c[i][j]);
				}else if((i + 1 + j + 1)%3 == 1){
					one.add(c[i][j]);
				}else{
					two.add(c[i][j]);
				}
			}
		}	
		//		System.out.println("zero");
		//		for(int i = 0;i < zero.size();i++){
		//			System.out.println(zero.get(i));
		//		}
		//		System.out.println("one");
		//		for(int i = 0;i < one.size();i++){
		//			System.out.println(one.get(i));
		//		}
		//		System.out.println("two");
		//		for(int i = 0;i < two.size();i++){
		//			System.out.println(two.get(i));
		//		}
		memo = new int[3][C];
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < C;j++){
				if(i == 0){
					for(int k = 0;k < zero.size();k++){
						memo[i][j] += d[zero.get(k)][j];
					}
				}else if(i == 1){
					for(int k = 0;k < one.size();k++){
						memo[i][j] += d[one.get(k)][j];
					}

				}else{
					for(int k = 0;k < two.size();k++){
						memo[i][j] += d[two.get(k)][j];
					}
				}
			}

		}

		boolean[] used = new boolean[C];
		dfs(0, 0, zero, used);
		System.out.println(ans);


	}
	static void dfs(int p,int sum,ArrayList<Integer> data,boolean[] used){
		if(sum > ans){
			return;
		}
		if(p == 3){
			ans = Math.min(ans, sum);
			return;
		}
		for(int color = 0;color < C;color++){
			int sub = 0;
			if(used[color] != true){
				used[color] = true;
				sub = memo[p][color];
//				for(int i = 0;i <data.size();i++){
//					sub += d[data.get(i)][color];
//				}
				if(p == 0){
					dfs(p+1, sum+sub, one,used);
				}else if(p == 1){
					dfs(p+1, sum+sub, two,used);	
				}else{
					dfs(p+1, sum+sub, two,used);	
				}
				used[color]  = false;
			}
		}

	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 93620
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[5010];
ll dp[5010];
int main()
{
	int n, k;
	while(~scanf("%d%d",&n, &k))
	{
		for(int i=1; i<=n;i++)
		scanf("%lld",&a[i]);
		
		sort(a+1, a+1+n);

		memset(dp,0,sizeof dp);
		
		dp[1] = a[1]<k?1:0;
		for(int i=2;i<=n;i++)
		{
			if(a[i] >= k)
			dp[i] = dp[i-1];
			else 
			{
				ll sum = 0;
				for(int j=1;j<=dp[i-1];j++)
				sum += a[j];
				sum += a[i];
				
				if(sum < k)
				{
					if(dp[i-1] == i-1)
					dp[i] = i;
					else dp[i] = dp[i-1];
					continue;
				}
				ll ans = 0;
				for(int j=1;j<=dp[i-1];j++)
				{
					if(sum-a[j] >= k)
					{
						ans++;
						sum -= a[j];
					}
				}
				dp[i] = ans;
			}
		}
		
		printf("%lld\n", dp[n]);
	}
	return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    int x=a+b;
    if(x%2==0) cout<<x/2<<endl;
    else cout<<x/2+1<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

 int main(void){
         long long a,b,c,d,gcd,lcm;
         while( scanf("%lld %lld",&a,&b) !=EOF){
             c=a; d=b;
             while(1){
                if(a>b){
                  a=a-b;
                }else if(a<b){
                  b=b-a;
                }if( a==b){
                  break;
                }
              }
                 gcd =a;
                 lcm =c*d/a;
              printf("%lld %lld\n",gcd,lcm);
}
             return 0;
} 
                  

Measured memory_bytes: 596
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

int n, a[200], b[200];
char s[200];

char rot(char ch, int a) { return 'a' + (ch-'a'+a)%26; }

int main() {
    for(;;) {
        scanf("%d", &n);
        if(n==0) return 0;
        scanf("%s", s);
        rep(i, n) scanf("%d%d", a+i, b+i);
        rep(i, n) a[i]--, b[i]--;
        for(int i=n-1; i>=0; i--) {
            swap(s[a[i]], s[b[i]]);
            s[a[i]] = rot(s[a[i]], b[i]-a[i]);
            s[b[i]] = rot(s[b[i]], b[i]-a[i]);
        }
        puts(s);
    }
}

Measured memory_bytes: 0
N, M = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
require 'prime'

def combination_mod(a, b)
  return combination_mod(a, a - b) if b > a - b
  mul = div = 1
  b.times do |i|
    mul *= a - i
    div *= i + 1
    mul %= MOD
    div %= MOD
  end
  mul * pow_mod(div, MOD - 2) % MOD
end

def pow_mod(a, pow)
  if pow == 0
    1
  elsif pow.odd?
    a * pow_mod(a, pow - 1) % MOD
  else
    half = pow_mod(a, pow / 2)
    half * half % MOD
  end
end

ans = 1
M.prime_division.each do |prime|
  x = prime[1]
  ans *= combination_mod(x + N - 1, N - 1)
  ans %= MOD
end

puts ans


Measured memory_bytes: 3964
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	long long int a, b, c;
	cin >> a >> b >> c;
	long long int ab = a + b, bc = b + c, ac = a + c;
	vector<string>s(N);
	for (auto &i : s)cin >> i;
	set<int>AB;
	set<int>AC;
	set<int>BC;
	for (int i = 0; i < N; i++) {
		if (s[i] == "AB")AB.insert(i);
		else if (s[i] == "AC")AC.insert(i);
		else BC.insert(i);
	}
	AC.insert(MOD);
	AB.insert(MOD);
	BC.insert(MOD);
	vector<char>ans;
	int cnt = 0;
	for (auto i : s) {
		if (i == "AB") {
			if (ab == 0) {
				cout << "No\n";
				return 0;
			}
			if (ac < bc) {
				ac++;
				bc--;
				ans.push_back('A');
			}
			else if(ac>bc){
				bc++;
				ac--;
				ans.push_back('B');
			}
			else if(*AC.lower_bound(cnt)<*BC.lower_bound(cnt)){
				ac++;
				bc--;
				ans.push_back('A');
			}
			else {
				bc++;
				ac--;
				ans.push_back('B');
			}
		}
		else if (i == "AC") {
			if (ac == 0) {
				cout << "No\n";
				return 0;
			}
			if (ab < bc) {
				ab++;
				bc--;
				ans.push_back('A');
			}
			else if (ab > bc) {
				ab--;
				bc++;
				ans.push_back('C');
			}
			else if (*AB.lower_bound(cnt) < *BC.lower_bound(cnt)) {
				ab++;
				bc--;
				ans.push_back('A');
			}
			else {
				ab--;
				bc++;
				ans.push_back('C');
			}
		}
		else {
			if (bc == 0) {
				cout << "No\n";
				return 0;
			}
			if (ab < ac) {
				ab++;
				ac--;
				ans.push_back('B');
			}
			else if (ab > ac) {
				ab --;
				ac++;
				ans.push_back('C');
			}
			else if (*AB.lower_bound(cnt) < *AC.lower_bound(cnt)) {
				ab++;
				ac--;
				ans.push_back('B');
			}
			else {
				ab--;
				ac++;
				ans.push_back('C');
			}
		}
		if (ab > a + b + c || ac > a + b + c || bc > a + b + c) {
			cout << "No\n";
		}
		cnt++;
	}
	cout << "Yes\n";
	for (auto i : ans)cout << i << endl;
}


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


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X);
  vector<ll> B(Y);
  vector<ll> C(Z);
  // A[0]=100'000'000'000;
  // B[0]=100'000'000'000;
  // C[0]=100'000'000'000;

  for (int i=1; i<=X; i++) cin >> A[i-1];
  for (int i=1; i<=Y; i++) cin >> B[i-1];
  for (int i=1; i<=Z; i++) cin >> C[i-1];
  sort(A.begin(),A.end(),greater<ll>());
  sort(B.begin(),B.end(),greater<ll>());
  sort(C.begin(),C.end(),greater<ll>());
  // for (ll i: A) cout<<i<<" ";
  // cout<<endl;
  // for (ll i: B) cout<<i<<" ";
  // cout<<endl;
  // for (ll i: C) cout<<i<<" ";
  // cout<<endl;

  vector<ll> firsty(K*K+10,0);

  for (int i=0; i<min(X,K); i++){
    for (int j=0; j<min(Y,K); j++){
      firsty[i+K*j]=A[i]+B[j];
    }
  }

  sort(firsty.begin(),firsty.end(),greater<ll>());

  vector<ll> secondy(K*K+10,0);

  for (int i=0; i<min(Z,K); i++){
    for (int j=0; j<min(K,X*Y); j++){
      secondy[i+K*j]=C[i]+firsty[j];
    }
  }

  sort(secondy.begin(),secondy.end(),greater<ll>());

  for (int i=0; i<K; i++) cout<<secondy[i]<<endl;

  

} 

Measured memory_bytes: 140928
#include <cstdio>
#include <cmath>

int main()
{
    size_t a, b;
    int c;
    scanf("%lu %lu.%d", &a, &b, &c);
    size_t prod = a * b;
    prod += a * c / 100;
    printf("%lu", prod);
    return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>

int main(void){
  int h, m, s;
  scanf("%d", &s);
  h = s/3600;
  s = s%3600;
  m = s/60;
  s = s%60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}



Measured memory_bytes: 2136
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		if (N%2 == 0) {
			System.out.println(N/2);
		} else {
			System.out.println((N/2) + 1);
		}
	}
}


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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    int X, Y;
    cin >> X >> Y;

    bool ret = false;
    rep(i, X+1) {
        int j = X-i;
        if (i*2 + j*4 == Y) {
            ret = true;
            break;
        }
    }

    if (ret) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
	int key;
	Node *right,*left,*parent;
};

Node *root,*NIL;

Node *find(Node *u,int k){
	while(u!=NIL&&k!=u->key){
		if(k<u->key)u=u->left;
		else u=u->right;
	}
	return u;
}

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u){
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(Node *u){
		if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n,i,x;
	string com;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		cin>>com;
		if(com[0]=='f'){
			scanf("%d",&x);
			Node *t=find(root,x);
			if(t!=NIL)printf("yes\n");
			else printf("no\n");
		}else if(com=="insert"){
			scanf("%d",&x);
			insert(x);
		}else if(com=="print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 21956
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1000000000001010;
int main(){
int n;cin>>n;
string s;cin>>s;
int count=0;
rep(i,n-1){
    if(s[i]==s[i+1])count++;
}
int ans=0;
ans=n-count;
cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int N=sc.nextInt();
		int i=sc.nextInt();
		pw.println(N+1-i);
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M=1e5+5;
const ll INF=1e15;
const int MOD=1e9+7;

int n;
ll dp[M][3];
vi vec[M];

ll DP(int v,int c,int r){
	if (dp[v][c] != -1) return dp[v][c];
	dp[v][c] = 1;
	fp(i,0,vec[v].size()){
		int &y=vec[v][i];
		if (y == r) continue;
		if (c == 0) dp[v][0] = (((DP(y,1,v)+DP(y,0,v)) % MOD)*dp[v][0]) % MOD;
		else dp[v][1] = (dp[v][1]*DP(y,0,v)) % MOD;
	}
	return dp[v][c];
}

int main(){

	fastio;
	cin >> n;
	fp(i,0,n+1){
		dp[i][0] = -1;
		dp[i][1] = -1;
	}
	fp(i,1,n){
		int a,b; cin >> a >> b;
		vec[a].pb(b);
		vec[b].pb(a);
	}
	cout << (DP(1,1,0) + DP(1,0,0)) % MOD << "\n";

	return 0;
}


Measured memory_bytes: 19720
#include <stdio.h>
int search(int A[],int n,int key)
{
  int i=0;
  A[n]=key;
  while(A[i]!=key)
  {
    i++;
  }
  if(i!=n)
    {
      return 1;
    }
  else
    {
      return 0; /*見つかったら真を返す*/
    }
  
}
int main()
{
  int i,N,A[10001],q,key,sum=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++)
  {
    scanf("%d",&key);
    if(search(A,N,key))
    {
      sum++;
    }
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

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

	ll n;
	cin>>n;
  	cout<<n+(n*n)+(n*n*n)<<endl;

	return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cmath> 
int N, ans;
double D, X, Y; 
int main()
{
	scanf("%d%lf", &N, &D);
	for(int i=1;i<=N;i++)
	{
		scanf("%lf%lf", &X, &Y);
		double len = sqrt(X*X+Y*Y);
		if(len<=D)
		    ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2156
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var result = (function(n,data) {

    return data.split(' ').slice(0,n).reverse().join(' ');

  }(lines.shift(),lines.shift()
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7644
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if (c-a-b<=0) cout<<"No"<<endl;
	else{
		ll p,q;
		ll m=4*a*b;ll n=(c-a-b)*(c-a-b);
		if (m<n) cout<<"Yes"<<endl;else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5+5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
bool d[mxn];
int main(){
	int n,i,k;cin>>n>>k;vi v(n);for(i=0;i<n;i++) cin>>v[i];
	for(i=0;i<=k;i++){
		for(auto j:v) if(j<=i&&!d[i-j]) d[i]=1;
	}cout<<(d[k]?"First\n":"Second\n");
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String s = sc.next();

		int len = s.length();

		loop: for (int i = 0; i < s.length() / 2; i++) {
			len -= 2;
			for (int j = 0; j < len / 2; j++) {
				if (s.charAt(j) != s.charAt(j + len / 2)) {
					continue loop;
				}
			}

			System.out.println(len);
			break;

		}

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
void fastios() { ios_base::sync_with_stdio(0); cin.tie(0); }

static const int N = 10005;

struct vertex {
	int id;
	int p;
	int d;
	bool operator<(const vertex & another) const {
		return (d != another.d ? d>another.d : id>another.id);
	}
};

struct edge {
	int end;
	int w;
};

int main() {
	fastios();
	int n;
	cin >> n;
	vector<vector<edge>> E(N);
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(i, k) {
			int v, c;
			cin >> v >> c;
			E[u].push_back({ v,c });
		}
	}
	//
	priority_queue<vertex> pq;
	vi color(N, 0), dist(N, 0);
	pq.push({ 0,-1,0 });
	while (pq.size() > 0) {
		vertex v = pq.top();
		pq.pop();
		if (color[v.id] == 1) continue;
		dist[v.id] = v.d;
		color[v.id] = 1;
		Loop(j, E[v.id].size()) {
			pq.push({ E[v.id][j].end, v.id, dist[v.id] + E[v.id][j].w });
		}
	}
	Loop(i, n) {
		cout << i << " " << dist[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 14144
import math

def rot60(s, t):
    v = t - s
    a = 1/2 + complex(0, (math.sqrt(3)/2))
    return v * a + s

def pr(p):
    x = p.real
    y = p.imag
    print('%.10f %.10f'%(x,y))

def dfs(p1, p2, n):
    if n == 0:
        return
    s = (p2-p1)*(1/3) + p1
    t = (p2-p1)*(2/3) + p1
    u = rot60(s, t)
    dfs(p1, s, n-1)
    pr(s)
    dfs(s, u, n-1)
    pr(u)
    dfs(u, t, n-1)
    pr(t)
    dfs(t, p2, n-1)

n = int(input())
s = (0 + 0j)
t = (100 + 0j)
pr(s)
dfs(s, t, n)
pr(t)


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

long long all7(long long a)
{
    long long count = 0;
    while(a > 0)
    {
        if(a % 10 != 7)
        {
            count = 0;
            break;
        }
        a /= 10;
        count++;
    }

    return count;
}

int main(void)
{
    long long K;
    cin >> K;

    K *= 9;
    if(K % 7 == 0)
    {
        K /= 7;
    }

    long long amari = 10 % K;
    int i = 1;
    while (i <= 9 * K)
    {
        if(amari == 1)
        {
            cout << i << endl;
            return 0;
        }
        amari *= 10;
        amari %= K;
        i++;
    }
    
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3628
N = gets.to_i
A = gets.split.map(&:to_i)

CACHE = [0]

sum = 0
counter = Hash.new(0)

A.each do |a|
  counter[a] += 1
end

(1..N).each do |n|
  sum += n

  CACHE << sum
end

total = 0

(1..N).each do |n|
  cnt = counter[n]
  next if cnt == 0

  total += CACHE[cnt - 1]
end

A.each do |a|
  cnt = counter[a]

  if cnt > 1
    puts (total - CACHE[cnt - 1] + CACHE[cnt - 2])
  else
    puts total
  end
end


Measured memory_bytes: 30344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int a,b,c;cin>>a>>b>>c;
    int cnt=0;
    while(1){
        if(a%2==0&(a==b&&b==c)){co(-1);return 0;}
        if(a%2==1||b%2==1||c%2==1){co(cnt);return 0;}
        int aa=a/2,bb=b/2,cc=c/2;
        a=bb+cc;b=aa+cc;c=aa+bb;
        cnt++;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int[] T, O;

int calc(int x) {
    return x * (x + 1) * (x + 2) / 6;
}

void prepare() {
    for (int i = 1; ; i++) {
        int x = calc(i);
        if (x > 1000000) break;
        T ~= x;
        if (x % 2 == 1) O ~= x;
    }
    T.sort!"a > b";
    O.sort!"a > b";
}

void main() {
    prepare;
    int N;
    bool input() {
        scanf("%d\n", &N);
        if (N == 0) return false;
        return true;
    }

    auto dp = new long[1000001];
    dp[] = 1L << 30;
    dp[0] = 0;
    foreach (t; T) {
        foreach (i; 0 .. 1000001) {
            if (i + t > 1000000) continue;
            dp[i + t] = min(dp[i + t], dp[i] + 1);
        }
    }

    auto dp2 = new long[1000001];
    dp2[] = 1L << 30;
    dp2[0] = 0;
    foreach (t; O) {
        foreach (i; 0 .. 1000001) {
            if (i + t > 1000000) continue;
            dp2[i + t] = min(dp2[i + t], dp2[i] + 1);
        }
    }

    void solve() {
        writeln(dp[N], " ", dp2[N]);
    }
    while (input) solve;
}

Measured memory_bytes: 19196
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    int n; cin>>n;
    ll x; cin>>x;
    vector<ll> len(n+1, 1), lp(n+1, 0);
    for(int i=0; i<n; i++){
        len[i+1] = len[i] * 2 + 3;
        lp[i+1] = lp[i] * 2 + 1;
    }

    ll ans = 0;
    ll lb = 1, ub = len[n];
    for(int i=0; i<n; i++){
        ll mid = (lb + ub) / 2;
        int level = n - i;

        if(lb == x) break;
        if(ub == x){
            ans += lp[level] * 2 + 1;
            break;
        }
        
        if(mid < x){
            lb = mid + 1;
            ub--;
            ans += lp[level] + 1;
        }
        else if(x < mid){
            ub = mid - 1;
            lb++;
        }
        else{
            ans += lp[level] + 1;
            break;
        }

        if(i == n - 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N, X, Y;
    cin >> N >> X >> Y;

    map<ll, ll> d;

    rep1(i,N) rep1(j,N) if(i < j){
        ll nowi = i, nowj = j;
        ll D = 0;

        if(nowi <= X) D += X - i, nowi = X;
        if(nowj >= Y) D += j - Y, nowj = Y;

        D += min(nowj - nowi, nowi - X + Y - nowj + 1);
        d[D]++;
    }

    rep1(k,N-1){
        print(d[k]);
    }


    return 0;
}

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

string A, B;
int chk = 1, lef[2019], rig[2019], ans = 1e9;

int main(){
	cin >> A >> B;
	int n = A.size();
	for(int i=0; i<n; i++){
		if(B[i] == '1') chk = 0;
	}
	if(chk == 1){
		int chk2 = 1;
		for(int i=0; i<n; i++){
			if(A[i] == '1') chk2 = 0;
		}
		if(chk2 == 1) cout << 0 << endl;
		else cout << -1 << endl;
	}else{
		for(int i=0; i<n; i++){
			int f1 = 1, f2 = 1;
			for(int j=0; j<n; j++){
				int p1;
				if(i>=j) p1 = i-j;
				else p1 = n+i-j;
				if(B[p1] == '1' && f1 == 1){
					lef[i] = j;
					f1 = 0;
				}
				int p2 = (i+j)%n;
				if(B[p2] == '1' && f2 == 1){
					rig[i] = j;
					f2 = 0;
				}
			}
		}

		for(int i=0; i<n; i++){
			int dif = 0;
			int leftma = -1;
			vector<pair<int, int>> arr;
			for(int j=0; j<n; j++){
				if(A[(j+i)%n] != B[j]) dif++;
				if(A[(j+i)%n] == '1' && B[j] == '0'){
					arr.push_back({rig[(i+j)%n], lef[(i+j)%n]});
					if(leftma < lef[(i+j)%n]) leftma = lef[(i+j)%n];
				}
			}
			int L = 0, mi = 1e6;
			if(arr.size() != 0){
				sort(arr.begin(), arr.end());
				//左，右1回のみ
				if(arr[arr.size()-1].first <= n-i) mi = min(mi, n-i);
				if(leftma <= i) mi = min(mi, i);
				//左右i，右左i
				for(int j=arr.size()-1; j>=0; j--){
					if(j == arr.size()-1){
						mi = min(mi, arr[j].first + min(abs(n-i-arr[j].first), n-abs(n-i-arr[j].first)));
					}else{
						L = max(L, arr[j+1].second);
						mi = min(mi, 2*arr[j].first + L + min(abs(L-i), n-abs(L-i)));
						mi = min(mi, 2*L + arr[j].first + min(abs(n-i-arr[j].first), n-abs(n-i-arr[j].first)));
						mi = min(mi, leftma + min(abs(leftma-i), n-abs(leftma-i)));
					}
				}
			}else{
				mi = min(i, n-i);
			}
			ans = min(ans, mi + dif);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int k = sc.nextInt();
        String s = sc.next();

        if (s.length() > k)
            System.out.println(s.substring(0, k) + "...");
        else
            System.out.println(s);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 36508
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S;
    cin >> S;
    ll s  =S.size();
    ll make = 0;
    rep(i,s){
        if(S[i] == 'x')make++;
    }
    if(make <= 7)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
// code.begin();
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back 
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define my_time ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define endl "\n"
#define MOD 1000000007
const long long int INF=1e18;
#define mod 1000000007
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
//find_by_order(x)
//order_of_key(x)  


int power(int x,unsigned int y)
{
    int res=1;
    
    while(y>0)
    {
        // if y is odd multiply with result
        if(y&1)
        res=res*x;
        
        y=y>>1; // y=y/2;
        x=x*x;
        
    }
    return res;
}

int gcd(int a,int b)
{
    if(b==0)
    return a;
    
    return gcd(b,a%b);
}

ll  max3(ll  a, ll  b, ll c)
{
    return max(c, max(a, b));
}
int min3(int a, int  b, int  c)
{
    return min(a, min(b, c));
}

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int logg(int  a)
{
    int  x = 0;
    while (a > 1)
    {
        x++;
        a /= 2;
    }
    return x;
}


int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}



int  main(){
	my_time;

int t;
t=1;
//cin>>t;int test=0;
while(t--)
{
    int n;
    cin>>n;
    int arr[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    {
        cout<<0<<endl;
        continue;
    }
    
    int dp[n+1]{0};
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    //cout<<dp[1]<<endl;
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
       // cout<<dp[i]<<endl;
    }
    
    
    cout<<dp[n-1]<<endl;
    
    
    
    
    
    
}
    return 0;
}


//code.end();





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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++) {
        if (s.substr(i, n - i) == t.substr(0, n - i)) {
            cout << (n * 2 - (n - i)) << endl;
            return 0;
        }
    }
    cout << (n * 2) << endl; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
int main() {
	long long N, ans = 0;
	scanf("%lld", &N);
	set<long long> guess;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) guess.insert(i), guess.insert(N / i);
	}
	for (long long i = 1; i * i < N; ++i) {
		if ((N - 1) % i == 0) guess.insert(i), guess.insert((N - 1) / i);
	}
	guess.erase(1);
	for (long long i: guess) {
		long long T = N;
		while (T % i == 0) T /= i;
		if ((T - 1) % i == 0) ++ans;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(min(a,b)<c && c<max(a,b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int a, b, c;
    int k;
    int n;
 
    scanf("%d%d%d", &a, &b, &c);
    n = 0;
    for (k = a; k <= b; k++) {
        if (c % k == 0) n++;
    }
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 2128
N=int(input())
if N<=1000:
    print(1000-N)
if 2000>=N>1000:
    print(2000-N)
if 3000>=N>2000:
    print(3000-N)
if 4000>=N>3000:
    print(4000-N)
if 5000>=N>4000:
    print(5000-N)
if 6000>=N>5000:
    print(6000-N)
if 7000>=N>6000:
    print(7000-N)
if 8000>=N>7000:
    print(8000-N)
if 9000>=N>8000:
    print(9000-N)
if 10000>=N>=9000:
    print(10000-N)

Measured memory_bytes: 9116
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
    int x, i, j,t;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++){
        if(A[j] <= x){
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;

    return i + 1;
}

int main(){
    int i, q;

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

    q = partition(0, n - 1);

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

    return 0;
}


Measured memory_bytes: 3120
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)44e15;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	llint n,i,m,j;cin>>n>>m;
	vector<llint>a(n);for(i=0;i<n;i++){cin>>a[i];}
	vector<int>oya(n);for(i=0;i<n;i++){oya[i]=i;}
	vector<int>ran(n);
	for(i=0;i<m;i++){
		int x,y;cin>>x>>y;
		while(oya[x]!=x){x=oya[x];}
		while(oya[y]!=y){y=oya[y];}
		//if(x==y){cerr<<"de";continue;}
		if(ran[x]<ran[y]){swap(x,y);}
		if(ran[x]==ran[y]){ran[x]++;}
		oya[y]=x;
	}
	vector<int>atu(n);int t=0;
	for(i=0;i<n;i++){
		//int x=i;while(oya[x]!=x){x=oya[x];}
		if(oya[i]!=i){atu[i]=-1;}
		else{atu[i]=t;t++;}
	}
	vector<vector<int>>ren(t);
	if(t==1){cout<<0<<endl;RE;}
	if(n<2*t-2){cout<<"Impossible"<<endl;RE;}
	
	for(i=0;i<n;i++){
		int x=i;while(oya[x]!=x){x=oya[x];}
		ren[atu[x]].pub(a[i]);
	}
	for(i=0;i<t;i++){SO(ren[i]);}
	vector<llint>yko;
	llint ans=0;
	for(i=0;i<t;i++){
		ans+=ren[i][0];
		for(j=1;j<ren[i].size();j++){yko.pub(ren[i][j]);}
	}
	SO(yko);
	for(i=0;i<t-2;i++){ans+=yko[i];}
	cout<<ans<<endl;
	//数字が低い方から貪欲につなぐ
	//まず,どの代表からもひとつづつえらぶ
	//そして、t-2個余計に選ぶ
	return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(){
	int times;
	int a=0,b=0,c=0,d=0;
	scanf("%d", &times);
	for(int i=0;i<times;i++){
		char word[10];
		scanf("%s", word);
		if(word[0] == 'A'){
			a++;
		}else if(word[0] == 'W'){
			b++;
		}else if(word[0] == 'T'){
			c++;
		}else if(word[0] == 'R'){
			d++;
		}
	}
		printf("AC x %d\n", a);
		printf("WA x %d\n", b);
		printf("TLE x %d\n", c);
		printf("RE x %d\n", d);
	
	
	return 0;
}

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

int main()
{
 int a,b;
  cin >> a >> b;
	int sum = 1, cnt = 0;
  
  while (sum < b)
  {
   	 cnt++;
    sum +=  a-1;
  }
  cout << cnt << endl;
}

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

int two(int x)
{
  int r=0;
  while(x%2==0)
  {
    x/=2;
    r++;
  }
  return r;
}

int main()
{
  int n,ans;
  ans=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    ans+=two(a.at(i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3676
n=list(input())
for i in range(len(n)):
    n[i]=int(n[i])

for i in range(n[0],10):
    if(n[0]==i):
        for i2 in range(n[1],10):
            for i3 in range(n[2],10):
                if(i==i2==i3):
                    print(i*100+i2*10+i3)
                    exit(0)
    else:
        for i2 in range(1,10):
            for i3 in range(1,10):
                if(i==i2==i3):
                    print(i*100+i2*10+i3)
                    exit(0)

Measured memory_bytes: 3064
<?php
// Here your code !
$result = array();
$s = trim(fgets(STDIN));    // ?§?

$h = floor($s / 3600);
$s %= 3600;
$m = floor($s / 60);
$s %= 60;
$result = array($h,$m,$s);
echo implode(":",$result);
?>

Measured memory_bytes: 15332