akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;

namespace ALDS1_8_A {
    class Node {
        public int Key { get; set; }
        public Node Parent { get; set; }
        public Node Left { get; set; }
        public Node Right { get; set; }

        public Node(int key = default(int), Node parent = null) {
            Key = key;
            Parent = parent;
        }
    }

    class Problem {
        private Node _root;
        private StringBuilder _sb;

        public void Run() {
            _sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            SetRoot();
            for (int i = 1; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');

                switch (input[0]) {
                    case "insert":
                        Insert(int.Parse(input[1]));
                        break;
                    case "print":
                        Inorder(_root);
                        _sb.AppendLine();
                        Preorder(_root);
                        _sb.AppendLine();
                        break;
                }
            }
            Console.Write(_sb);
        }

        private void SetRoot() {
            string[] input = Console.ReadLine().Split(' ');
            _root = new Node(int.Parse(input[1]));
        }

        private void Insert(int key) {
            Node x = _root;
            Node y = null;
            while (x != null) {
                y = x;
                x = key < x.Key ? x.Left : x.Right;
            }

            Node z = new Node(key, parent: y);
            if (z.Key < y.Key)
                y.Left = z;
            else
                y.Right = z;
        }

        private void Inorder(Node node) {
            if (node == null)
                return;
            Inorder(node.Left);
            _sb.Append(" " + node.Key);
            Inorder(node.Right);
        }

        private void Preorder(Node node) {
            if (node == null)
                return;
            _sb.Append(" " + node.Key);
            Preorder(node.Left);
            Preorder(node.Right);
        }
    }

    class Program {
        static void Main(string[] args) {
            Problem p = new Problem();
            p.Run();
        }
    }
}

Measured memory_bytes: 78408
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int main() {
  ll n, a, b;
  std::cin >> n >> a >> b;
  if(b < a)
    std::swap(a, b);
  if(a % 2 == b % 2)
    std::cout << (b - a) / 2;
  else { 
    std::cout << std::min(a - 1 + b, 2 * n - a - b + 1) / 2;
  }
  return 0;
}


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

string S;

void append(){
  set<char> s;
  for(char x='a'; x<='z'; x++){
    s.insert(x);
  }
  for(char c : S){
    s.erase(c);
  }
  S.push_back(* s.begin());
}

int main(){
  cin >> S;
  if(S.length() < 26){
    append();
    cout << S << endl;
    return 0;
  }
  else{
    char b = 'a';
    for(int i=25; i>=0; i--){
      if(S[i] < b){
        /*
        S.erase(i+1, 26);
        append();
        S.erase(i, 1);
        */
        for(int j=25; j>i; j--){
          if(S[j] > S[i]){
            swap(S[j], S[i]);
            break;
          }
        }
        for(int j=0; j<=i; j++){
          cout << S[j];
        }
        cout << endl;
        return 0;
      }
      else{
        b = S[i];
      }
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    int h, n;   cin >> h >> n;
    vector<pair<int, int>> cast(n);
    for(int i=0; i<n; i++)  cin >> cast.at(i).first >> cast.at(i).second;
    vector<vector<ll>> dp(n+1, vector<ll>(h+1, 1e+15)); 
    dp[0][0] = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=h;j++){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][min(j+cast[i].first, h)] = min(dp[i+1][min(j+cast[i].first, h)], dp[i+1][j]+cast[i].second);
        }
    }
    cout << dp[n][h] << endl;

}



Measured memory_bytes: 78592
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        $(writeln!(stderr(), "{} = {:?}", stringify!($arg), $arg).unwrap());*
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, K) = read!(i64, i64);

    let mut s = 0_i64;

    let n = N / K;
    s += n * n * n;

    if K % 2 == 0 {
        let l = (N + K / 2) / K;
        s += l * l * l;
    }

    println!("{}", s)
}


Measured memory_bytes: 4352
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B) = read!(i64, i64);
    let ok = 1 <= A && A <= 9 && 1 <= B && B <= 9;
    if ok {
        println!("{}", A * B);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 4352
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define MX 200



int main()
{
	int a, b, c;
	cin >> a;
	int ans = a;
	for (int i = 0; i < a; i++) {
		cin >> b >> c;
		ans += (c - b);
	}
	printf("%d", ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a, const void *b){
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A > *B) return 1;
	if (*A < *B) return -1;
	return 0;
}

int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	int X[M];
	for(int i=0;i<M;i++)scanf("%d",&X[i]);
	
	qsort(X,M,sizeof(int),compare);
	
	int dif[M-1];
	for(int i=0;i<M-1;i++)dif[i]=X[i+1]-X[i];
	
	qsort(dif,M-1,sizeof(int),compare);
	
	int ans=0;
	for(int i=0;i<M-N;i++)ans+=dif[i];
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1396
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int i=0,j=n-1;
	int ans=0;
	while(i<j){
		while(i<j&&s[j]=='W')j--;
		while(i<j&&s[i]=='R')i++;
		if(i!=j)ans++;
		i++;
		j--;
	}
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3764
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [n;a;b;c] = reads int
    let ls = Array.map (fun _ -> read int) [|1..n|]

    let rec dfs i x y z =
        if i = n then
            if List.exists ((=) 0) [x;y;z] then
                100000
            else
                // 下の再帰だと一本目の材料を選んだときにも合成魔法を使用している
                // A,B,Cに大して材料は最低一本あるためMP30を引く
                abs (a - x) + abs (b - y) + abs (c - z) - 30
        else
            [
                dfs (i + 1) x y z
                dfs (i + 1) (x + ls.[i]) y z + 10
                dfs (i + 1) x (y + ls.[i]) z + 10
                dfs (i + 1) x y (z + ls.[i]) + 10
            ]
            |> List.min

    dfs 0 0 0 0
    |> printfn "%i"

    0

Measured memory_bytes: 18260
package main

import (
	"fmt"
)

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)

	if a - b >= 0 {
		fmt.Println("delicious")
		return
	}
	if (b-a) <= x {
		fmt.Println("safe")
		return
	}
	fmt.Println("dangerous")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const long double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;

void solve(){     
    ll x, k, d;
    cin >> x >> k >> d;
    ll kol = abs(x) / d;
    
    if (k <= kol){
        if (x > 0)
            cout << abs(x - k * d);
        else cout << abs(x + k * d);
    return;
    }
    if (x < 0) x = -1 * (abs(x) % d);
    else x %= d;
    k -= kol;

    if (k % 2 == 0) cout << abs(x);
    else{
        if (x < 0) cout << abs(x + d);
        else cout << abs(x - d) ;
    }
}
int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(6);
    //freopen("input.txt", "r", stdin);   
    //freopen("sausage.in","r",stdin); freopen("sausage.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++){
         solve();
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice=0,bob=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      alice += a.at(i);
    }
    else{
      bob += a.at(i);
    }
  }
  cout << alice - bob << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val num = IntArray(n) { -1 }

    var failed = false
    repeat(m) {
        val (d, i) = readLine()!!.split(" ").map { it.toInt() }

        if (failed) return@repeat

        if (num[d-1] == -1) {
            num[d-1] = i
        } else if (num[d-1] != i) {
            failed = true
        }
    }

    if (failed || (n > 1 && num[0] == 0)) {
        println("-1")
        return
    }

    if (num[0] == -1) {
        if (n == 1) {
            num[0] = 0
        } else {
            num[0] = 1
        }
    }

    num.forEachIndexed { index, i ->
        if (i == -1) {
            num[index] = 0
        }
    }

    println(num.joinToString(separator = ""))
}

Measured memory_bytes: 37868
X = int(input())
A = []
Amod = 0
j = 0
for i in range(1,10):
    A.append(i)
k=8
if X > 9:
    while(1):
        Amod = A[j]%10
        if Amod == 0:
            A.append(A[j]*10+0)
            A.append(A[j]*10+1)
            k+=2
        elif Amod == 9:
            A.append(A[j]*10+8)
            A.append(A[j]*10+9)
            k+=2
        else:
            A.append(A[j]*10+Amod-1)
            A.append(A[j]*10+Amod)
            A.append(A[j]*10+Amod+1)
            k+=3
        if X <=k:
            break
        j+=1
print(A[X-1])

Measured memory_bytes: 7264
import Data.Monoid ((<>))

f :: [Int] -> Ordering -> Int
f [_] _ = 0
f (a:b:as) ord =
    if ord /= EQ && ord' /= EQ && ord /= ord'
        then f (b:as) EQ + 1
        else f (b:as) (ord <> ord')
  where ord' = compare a b
 
main = do
    n <- readLn :: IO Int
    a <- map read . words <$> getLine :: IO [Int]
    print $ 1 + f a EQ

Measured memory_bytes: 33148
#include <cstdio>
#include <algorithm>

using namespace std;

struct point
{
	int x,y,z;
};

point p[300000],e[300000];
int f[300000];
int i,k,n,fx,fy;
long long s;

inline bool cmp1(point x,point y)
{
	return x.x<y.x;
}

inline bool cmp2(point x,point y)
{
	return x.y<y.y;
}

inline bool cmp3(point x,point y)
{
	return x.z<y.z;
}

inline int getfather(int x)
{
	if (f[x]==x)
		return x;
	else
		return f[x]=getfather(f[x]);
}

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d%d",&p[i].x,&p[i].y),p[i].z=i;
	sort(p+1,p+n+1,cmp1);
	for (i=1;i<n;i++)
		k++,e[k].x=p[i].z,e[k].y=p[i+1].z,e[k].z=p[i+1].x-p[i].x;
	sort(p+1,p+n+1,cmp2);
	for (i=1;i<n;i++)
		k++,e[k].x=p[i].z,e[k].y=p[i+1].z,e[k].z=p[i+1].y-p[i].y;
	sort(e+1,e+k+1,cmp3);
	for (i=1;i<=n;i++)
		f[i]=i;
	for (i=1;i<=k;i++)
	{
		fx=getfather(e[i].x);
		fy=getfather(e[i].y);
		if (fx!=fy)
		{
			f[fx]=fy;
			s=s+e[i].z;
		}
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 5504
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

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

print(lcm(A, B))

Measured memory_bytes: 3064
#include<bits//stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m&&n!=0&&m!=0){
		string a[110];
		int b[110];
		long long sum=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
		}
		string c;
		for(int i=0;i<m;i++){
			cin>>c;
			for(int j=0;j<n;j++){
				bool l=true;
				for(int z=7;z>=0;z--){
					if(a[j][z]=='*') break;
					if(c[z]!=a[j][z]){
						 l=false;
						 break;
					 }
				}
				if(l){
					sum+=b[j];
					break;
				}
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, result;
    result = 0;
    cin >> N ;
    vector<int> a;
    
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        a.push_back(num);
    }
    sort(a.begin(), a.end());
    
    int idx = 1;
    for (int i = 0; i < a.size(); ) {
        int num = a.at(i);
        int count = 1;
        i++;
        while (i < a.size() && num == a.at(i)) {
            count++;
            i++;
            if (i >= a.size()) {
                break;
            }
        }
        if (num > count) {
            result += count;
        } else if (num < count) {
            result += count - num; 
        }
    }
    cout << result << endl;
	return 0;
}

Measured memory_bytes: 892
s = input()
pattern1 = 0
pattern2 = 0
for i in range(len(s)):
  if i %2 == 0:
    if s[i] == "0":
      pattern1 += 1
    else:
      pattern2 += 1
  else:
    if s[i] == "0":
      pattern2 += 1
    else:
      pattern1 += 1
print(min(pattern1,pattern2))

Measured memory_bytes: 66000
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 998244353;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int maxn = 3e3+5;

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

    int n, s;
    while(cin>>n>>s){
        ll ans = 0;
        vi a(n);
        forn(i,n) cin>>a[i];

        vvl dp(maxn, vl(maxn));

        forn(i,n){
            dp[i+1] = dp[i];

            // start new seq
            add_self(dp[i+1][a[i]], i+1);

            for(int j=0; j+a[i]<=s; ++j)
                add_self(dp[i+1][j+a[i]], dp[i][j]);
            
            add_self(ans, dp[i+1][s]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 70912
#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
    int root;
    struct Node* parent;
    struct Node* leftchild;
    struct Node* rightchild;
}Node;
Node* insertTree(Node* Tree, int data)
{
    Node* y = NULL;
    Node* x = Tree;
    Node* temp = (Node*)malloc(sizeof(Node));
    temp->root = data;
    temp->leftchild=temp->rightchild=temp->parent=NULL;
    while(x!=NULL)
    {
        y = x;
        if(temp->root < x->root){x = x->leftchild;}
        else{x = x->rightchild;}
    }
    temp->parent = y;
    if(y == NULL){Tree = temp;}
    else if(temp->root < y->root){y->leftchild = temp;}
    else{y->rightchild = temp;}
    return Tree;
}
void Preorder(Node* Tree)
{
    if(Tree==NULL)return;
    printf(" %d", Tree->root);
    Preorder(Tree->leftchild);
    Preorder(Tree->rightchild);
}
void inorder(Node* Tree)
{
    if(Tree==NULL)return;
    inorder(Tree->leftchild);
    printf(" %d", Tree->root);
    inorder(Tree->rightchild);
}
void finder(Node* Tree, int num)
{
    if(Tree==NULL){printf("no\n");return;}
    if(num==Tree->root){printf("yes\n");return;}
    else if(num>Tree->root){finder(Tree->rightchild, num);}
    else{finder(Tree->leftchild, num);}
}
int main() {
    int n;
    int node;
    int num;
    char str[10];
    Node* Tree = NULL;
    scanf("%d", &n);
    for(int i=0;i<n;i++)
    {
        scanf("%s ", str);
        if(str[0]=='i')
        {
            scanf("%d", &node);
            Tree = insertTree(Tree, node);
        }
        else if(str[0]=='f')
        {
            scanf("%d", &num);
            finder(Tree, num);
        }
        else if(str[0]=='p')
        {inorder(Tree);printf("\n");Preorder(Tree);printf("\n");}
    }
    return 0;
}



Measured memory_bytes: 20492
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	vector<ll> p;
	int count = 1;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1])
			count++;
		else {
			if (count >= 4) {
				p.push_back(a[i]);
				p.push_back(a[i]);
			}
			else if (count >= 2)
				p.push_back(a[i]);
			count = 1;
		}
	}
	if (count >= 4) {
		p.push_back(a[n - 1]);
		p.push_back(a[n - 1]);
	}
	else if (count >= 2)
		p.push_back(a[n - 1]);
	if (p.size() < 2) {
		cout << 0 << endl;
		return 0;
	}
	sort(p.rbegin(), p.rend());
	cout << p[0] * p[1] << endl;
	return 0;
}


Measured memory_bytes: 1660
# 頂点は0番から始まるとして、出力時に+1する
def graph(L):
    beki = 1
    for n in range(20):
        beki *= 2
        if beki > L: break

    ans = []
    Li = 1
    for i in range(n):
        ans += [(i + 1, i + 2, 0)]
        ans += [(i + 1, i + 2, Li)]
        Li *= 2

    Lnext = Li
    nokori_kosu = L - Li
    i = n - 1
    way_i = Li // 2
    while nokori_kosu > 0:
        while way_i > nokori_kosu:
            way_i //= 2
            i -= 1
        ans += [(i + 1, n + 1, Lnext)]
        Lnext += way_i
        nokori_kosu -= way_i
    print(n + 1, len(ans))
    for x in ans:
        print(*x)


L = int(input())
graph(L)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ans = n;
  for (long long i=1; i*i<=n; i++) {
    if (n%i==0) {
      ans = min(ans, i+n/i-2);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*


*/

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

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

#define endl '\n'
#define ld long double
#define ll long long
#define PI acos(-1.0)
#define OO 1e17
#define EPS 1e-12
#define MLOG 20
#define MAX 2* 100 * 1000+5
const int mod = 1e9 + 7;
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
#ifndef ONLINE_JUDGE
	freopen("E:\\Competitve\\solving\\input.txt", "r", stdin);
	freopen("E:\\Competitve\\solving\\output.txt", "w", stdout);
#endif
}
int n, k;
int a[1000 * 100 + 4];
int dp[100 * 1000 + 4];

int main(){
//	fast();

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

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

	for (int i = 1; i < n; i++){
		dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
		for (int d = 2; d <= k; d++){
			if (i >= d)
				dp[i] = min(dp[i], dp[i - d] + abs(a[i] - a[i - d]));
			else break;
		}
	}
	cout << dp[n - 1];
	return 0;

}

Measured memory_bytes: 1024
a=[int(input())for _ in[0]*int(input())]
m=a[-1]+1
def f(S):
 x=1
 while 2*x*-~x<m:
  if(S-x)%(2*x+1)==0:return 0
  x+=1
 return 1
print(sum(f(S)for S in a))


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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;
using Si = set<int>;
using vSi = vector<Si>;
using vvSi = vector<vSi>;

#define fi first
#define se second
#define INF 1e9 + 5
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	while (cin >> n) {
		vi v(n);
		for (int i = 0; i < n; ++i) cin >> v[i];
		sort(v.begin(), v.end());
		double ans = v[0];
		for (int i = 1; i < n; ++i) {
			ans = (ans + v[i])/2.0;
		}
		cout << ans << '\n';
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << (a <= b ? a : a - 1) << endl;


  
  return 0;
}

Measured memory_bytes: 256
import sys
from pprint import pprint

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

for _ in range(K):
    B = [0 for _ in range(N+1)]
    for i in range(N):
        l = max(0, i-A[i])
        r = min(i+A[i]+1 , N)
        B[l] += 1
        B[r] -= 1

    for i in range(N):
        B[i+1] += B[i]

    if A == B:
        break

    A = B[:]

print(*B[:N])

Measured memory_bytes: 174248
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

int a,b;
cin >> a >> b ;

if(b%a==0)
{
	cout << a+b << endl;
}
else
{
	cout << b-a << endl;
}


	return 0;
}











Measured memory_bytes: 3140
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    
    int n, m ,c;
    cin >> n >> m >> c;
    int b[m];
    int a[n][m];
    rep(i, 0, m){
        cin >> b[i];
    }

    rep(i, 0, n){
        rep(j, 0, m){
            cin >> a[i][j];
        }
    }
    int cnt = 0;
    rep(i, 0, n){
        int sum = 0;
        rep(j, 0, m){
            sum += a[i][j]*b[j];
        }

        if(sum+c > 0){
            cnt++;
        }
    }

    cout << cnt;

}



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

int main() {
    ll n;
    cin>>n;
    ll ans = 0;
    REP(i,n) {
        if (i % 3 != 0 && i % 5 != 0 && i% 15 != 0)
        ans += i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer x = Integer.parseInt(scanner.next());
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                if (i * j == x) {
                    System.out.println("Yes");
                    System.exit(0);

                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A==B&&B==C)cout << "Yes";else cout << "No";
    return 0;
}


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

inline ll gsc(ll a,ll b,ll p)
{
    ll ans=0;
    while(b)
    {
        if(b&1) ans=(ans+a)%p;
        a=(a+a)%p;
        b>>=1;
    }
    return ans%p;
}

inline ll qp(ll a,ll b,ll p)
{
    ll res=1;
    while(b)
    {
        if(b&1) { res=gsc(res,a,p); }
        a=gsc(a,a,p);
        b>>=1;
    }
    return res%p;
}

inline ll ol(ll x)
{
    ll res=x;
    for(ll i=2;i*i<=x;i++)
    {
        if(x%i==0)
        {
            res=res/i*(i-1);
            while(x%i==0) x/=i;
        }
    }
    if(x!=1) res=res/x*(x-1);
    return res;
}

int main()
{
    ll l;
    ll ans;
    scanf("%lld",&l);
    ll t=__gcd(7ll,l);
    ll c=9ll*l/t;
        if(__gcd(c,10ll)!=1)
        {
            printf("-1\n");
        }
        else
        {
            ll cnt=ol(c);
            ll ans=cnt;
            for(ll i=1;i*i<=cnt;i++)
            {
                if(cnt%i==0)
                {
                    if(qp(10ll,i,c)==1)     ans=min(ans,i);
                    if(qp(10ll,cnt/i,c)==1) ans=min(ans,cnt/i);
                }
            }
            printf("%lld\n",ans);
        }
    return 0;
}


Measured memory_bytes: 3828
import sys
input = sys.stdin.readline

k, a, b = [int(x) for x in input().split()]

biscuits = 0

if a + 1 > k or (b - a) <= 2:
    print(k + 1)
    sys.exit()

biscuits += b
k -= (a + 1)
biscuits += (b - a) * (k // 2) + (k % 2)

print(biscuits)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char x, y;
  cin >> x >> y;

  string s = "ABCDEF";
  int k = 9;
  for (int i = 0; i < 6; i++) {
    if (s[i] == x) k += i;
  }
  int l = 9;
  for (int j = 0; j < 6; j++) {
    if (s[j] == y) l += j;
  }

  if (k < l) cout << '<' << endl;
  else if (k > l) cout << '>' << endl;
  else cout << '=' << endl;

  return 0;
}


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

int main() {
  int s;
  cin >> s;
  
  cout << 3*s*s << endl;
    return 0;    
}

Measured memory_bytes: 256
from heapq import heappush, heappop
n = int(input())
a = list(map(int, input().split()))

s1 = [0] * 3*n
pq = []
s = 0
for i in range(3*n):
    if len(pq) < n:
        s += a[i]
        heappush(pq, a[i])
        if len(pq) == n:
            s1[i] = s
    else:
        s += a[i]
        heappush(pq, a[i])
        s -= heappop(pq)
        s1[i] = s


s2 = [0] * 3*n
pq = []
s = 0
for i in reversed(range(3*n)):
    if len(pq) < n:
        s += a[i]
        heappush(pq, -a[i])
        if len(pq) == n:
            s2[i] = s
    else:
        s += a[i]
        heappush(pq, -a[i])
        s -= -heappop(pq)
        s2[i] = s

ans = - 10**15
for i in range(n-1, 2*n):
    ans = max(ans, s1[i] - s2[i+1])
print(ans)


Measured memory_bytes: 37212
def toPostorder(prelist, inlist):
    parent = prelist[0]
    split_index = inlist.index(parent)
    if split_index != 0:
        yield from toPostorder(prelist[1:split_index + 1],inlist[0:split_index])
    if split_index != len(inlist)-1:
        yield from toPostorder(prelist[split_index + 1:],inlist[split_index + 1:])

    yield parent

nodes = dict()
n = int(input())
preorder = list(map(int, input().split()))
inorder = list(map(int, input().split()))
print(*toPostorder(preorder, inorder))


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define mod 1000000007
#define mx 200001
//#define y 20
using namespace std;
typedef long long int ll;
# define f(i, n) for(int i = 0;i < n; ++i)
typedef long long int ll;

void input()
{
    ll n; cin >> n;
    vector<ll>a(n);
    f(i, n) cin >> a[i];
    ll sum = 0;
    f(i, n){
        if(i & 1){
            sum -= a[i];
        }else{
            sum += a[i];
        }
    }
   vector<ll >ans(n);
   ans[0] = sum / 2;
   for(int i = 1; i < n; ++i)ans[i] = a[i - 1] - ans[i -1];
   f(i, n)cout << 2 * ans[i] << " ";cout << "\n";
}
int main()
{
    input();
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()) {
    if (s[i] != t[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3748
if(__name__ =="__main__"):
    N = int(input())
    a = [int(i) for i in input().split()]
    b = [0] * 512345
    left = 212345
    right = left + 1
    for i in range(N):
        if(i % 2 == (N-1) % 2):
            #b.insert(0,a[i])
            b[left] = a[i]
            left -= 1
        else:
            #b.append(a[i])
            b[right] = a[i]
            right += 1
        #print(b)
        # b = b[::-1] TLE:O(N)    
        #print(b)
    #b.extend(a)
    #print(' '.join(map(str,b)))
    for i in range(left+1,right):
        print(b[i],end=" ")

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    string s; cin >> s;
    int ss = s.size();
    ll res = 0;
    rep(i,ss){
        int j;
        if(s[i] == '0') j = 0;
        else if(s[i] == '1') j=1;
        else if(s[i] == '2') j=2;
        else if(s[i] == '3') j=3;
        else if(s[i] == '4') j=4;
        else if(s[i] == '5') j=5;
        else if(s[i] == '6') j=6;
        else if(s[i] == '7') j=7;
        else if(s[i] == '8') j=8;
        else if(s[i] == '9') j=9;
        res += j;
    }
    if(res % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3756
#include <stdio.h>

int main()
{
	int i, j, n=1;

	while(1) {
		scanf("%d", &n);
		if (n==0) break;
		else {
			int a[n][n], si[n], sj[n], total=0;

			for(i=0;i<n;i++) {
				si[i] = 0;
				for(j=0;j<n;j++) {
					scanf("%d", &a[i][j]);
					si[i] = si[i] + a[i][j];
				}
				total = total + si[i];
			} 

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

			for(j=0;j<n;j++) {
				sj[j] = 0;
				for(i=0;i<n;i++) sj[j] = sj[j] + a[i][j];
				printf("%5d", sj[j]);
			}
	
			printf("%5d\n", total);
		}
	}

	return 0;
}

Measured memory_bytes: 612
h, w = map(int, input().split())
list = []
for x in range(h):
    str = input()
    list.append(str)
for id in range(h + 2):
    if id == 0 or id == h + 1: print('#' * (w + 2))
    else: print('#' + list[id - 1] + '#')
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
char s[11];
int n;
void dfs(int p,int x){
    if(p==n) printf("%s\n",s);
    else{
        for(int i=0;i<=x;i++){
            s[p] = 'a' + i;
            dfs(p+1,x+(i==x));
        }
    }
}
int main(){
    cin>>n;
    dfs(0,0);
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

string s;
const int maxn = 1e5 + 5;
int dp[maxn][13];

int f(int i, int rem){
	if(i == (int) s.size()) return rem == 5;
	if(dp[i][rem] != -1) return dp[i][rem];
	int ret = 0;
	if(s[i] != '?'){
		int nextrem = rem * 10;
		nextrem += (s[i] - '0');
		nextrem %= 13;
		ret = add(ret, f(i + 1, nextrem));
	}
	else{
		for(int j = 0; j <= 9; j++){
			int nextrem = rem * 10;
			nextrem += j;
			nextrem %= 13;
			ret = add(ret, f(i + 1, nextrem));
		}
	}
	return dp[i][rem] = ret;
}

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

	cin >> s;
	memset(dp, -1, sizeof dp);
	cout << f(0, 0);
}

Measured memory_bytes: 13392
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using pii = pair<int,int>;
using lli = long long;

struct vec{
    lli x,y;
    vec() {}
    vec(lli x,lli y):x(x),y(y) {}
    vec operator+(const vec &rhs)const {
        return vec(x+rhs.x,y+rhs.y);
    }
    void read() {
        scanf("%lld %lld",&x,&y);
    }
    lli cross(const vec rhs)const {
        return x*rhs.y - y*rhs.x;
    }
    lli len() {
        return x*x + y*y;
    }
    bool operator<(const vec &rhs)const {
        if(y*rhs.y < 0) return y>0;
        else if(y==0) {
            if(x>0) return !(rhs.y==0 && rhs.x > 0);
            else return !(rhs.y>=0);
        } else if(rhs.y==0 && rhs.x>0) return false;
        else {
            return cross(rhs)>0;
        }
    }
}arr[100];
int n;

int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        arr[i].read();
        if(arr[i].x==0 && arr[i].y==0) {
            n--;i--;
        }
    }

    sort(arr,arr+n);
    lli ans=0;
    for(int i=0;i<n;i++) {
        vec tmp(0,0);
        for(int j=0;j<n;j++) {
            tmp = tmp + arr[(i+j)%n];
            ans = max(ans, tmp.len());
        }
    }
    printf("%.12Lf\n",sqrtl(ans));
    
    return 0;
}
    


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

int main(){
  int n; cin>>n;
  int l=0,r=n-1;
  cout<<l<<endl<<flush;
  string s; cin>>s;
  if(s=="Vacant") return 0;
  cout<<r<<endl<<flush;
  string t; cin>>t;
  if(t=="Vacant") return 0;
  while(true){
    int mid=(l+r)/2;
    cout<<mid<<endl<<flush;
    string x; cin>>x;
    if(x=="Vacant") return 0;
    if(mid%2==0 && s==x) l=mid;
    else if(mid%2==1 && s!=x) l=mid;
    else r=mid;
  }
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int x,y;
cin>>x>>y;
int a=2*x,b=4*x;
if(y%2==0&&y>=a&&y<=b)
{
	cout<<"Yes\n";
}
else
{
	cout<<"No\n";
}
return  0;
}






Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, t; cin >> n >> t;
	vector<int> a(n);
	int run = 0, last = 0, ans = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		ans += min(run, a[i]) - last;
		last = a[i];
		run = a[i] + t;
	}
	ans += run - last;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  REP(i,n) { cin >> a[i]; a[i]--;}
  REP(i,n) cin >> b[i];
  REP(i,n-1) cin >> c[i];
  int res = 0;
  REP(i,n) res += b[a[i]];
  REP(i,n-1) if(a[i]+1 == a[i+1]) res += c[a[i]];
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  string s; cin >> s;
  int q; cin >> q;
  bool rev = false;

  for (int i = 0; i < q; i++) {
    int t, f;
    string c;

    cin >> t;

    if (t == 1) {
      rev = !rev;
    } else {
      cin >> f >> c;

      if ((f == 1 && rev) || (f == 2 && !rev)) {
        s.append(c);
      } else if ((f == 1 && !rev) || (f == 2 && rev)) {
        s.insert(0, c);
      }
    }
  }

  if (rev) reverse(s.begin(), s.end());

  cout << s << endl;
}

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

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();

        a = (a % x == 0) ? a / x : a / x + 1;
        b /= x;

        System.out.println(b - a + 1);

    }

}



Measured memory_bytes: 23764
N = int(input())
A = list(map(int,input().split()))
now = 0
ans = []

A.append(0)
A.insert(0,0)
for i in range(len(A)-1):
    ans.append(abs(A[i+1]-A[i]))

sm = sum(ans)

for j in range(1,len(A)-1):
    print(sm-ans[j]-ans[j-1]+abs(A[j+1]-A[j-1]))

Measured memory_bytes: 14048
import math

n, d = map(int, input().split())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

tmp = []
ans = 0
for i in range(n):
    tmp.append(math.sqrt(x[i]**2 + y[i]**2))
    if tmp[i] <= d:
        ans += 1
print(ans)

Measured memory_bytes: 121500
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun main (str)
  (count #\1 str))

(defun main (line)
  (let ((gcded (reduce #'gcd line)))
    (loop for i from 0
          when (oddp gcded)
            return i
          do(setf gcded (ash gcded -1)))))

(princ (main (read-times (read))))


Measured memory_bytes: 19896