akhauriyash/Code-Regression huggingface dataset:
class NullNode():
    def __init__(self):
        self.id = None

null_node = NullNode()

class Node():
    def __init__(self, id):
        global null_node
        self.id = id
        self.parent = null_node
        self.left = null_node
        self.right = null_node

n = int(input())
node_list = [Node(id) for id in input().split()]

for i in range(n):
    node = node_list[i]
    node.left = node_list[2*i+1] if 2*i+1 < n else null_node
    node.right = node_list[2*i+2] if 2*i+2 < n else null_node
    if i != 0:
        node_list[i].parent = node_list[(i-1)//2]
    out_put = []
    out_put.append('node {}: '.format(i+1))
    out_put.append('key = {}, '.format(node.id))
    if node.parent.id is not None:
        out_put.append('parent key = {}, '.format(node.parent.id))
    if node.left.id is not None:
        out_put.append('left key = {}, '.format(node.left.id))
    if node.right.id is not None:
        out_put.append('right key = {}, '.format(node.right.id))
    print(''.join(out_put))




Measured memory_bytes: 5632
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d % s == 0)
    cout << ((d / s) <= t ? "Yes": "No") << '\n';
  else
    cout << ((d / s + 1) <= t ? "Yes": "No") << '\n';

  return 0;
}


Measured memory_bytes: 3124
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = sc.nextInt();
        int s = sc.nextInt();
        int p = sc.nextInt();

        String[] t = sc.next().split("");

        long ans = 0;

        for (int i = 0; i < k; i++) {
            boolean isAiko = false;
            for (int j = i; j < n; j += k) {
                long value = 0;
                switch (t[j]) {
                    case "r":
                        value = p;
                        break;
                    case "s":
                        value = r;
                        break;
                    case "p":
                        value = s;
                        break;
                }

                // なんでも出していいゾーン
                if (j < k) {
                    ans += value;
                }
                // k個前に出した組み合わせのとき
                else if (t[j].equals(t[j - k]) && !isAiko) {
                    // これをアイコにする
                    isAiko = true;
                } else {
                    //　前アイコで違う組み合わせだった
                    if (isAiko) {
                        isAiko = false;
                    }
                    ans += value;
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 34116
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner re=new Scanner(System.in);
        int a=0,b=0,c=0;
        int x;
        int num=re.nextInt();
        for (int i=0;i<num;i++){
            x=re.nextInt();
            if (x%4==0){
                c++;
            }
            else if(x%2==0){
                b++;
            }
            else
                a++;
        }
        if ((c>=a&&c!=0)||(c==0&&a==0)||(b==0&&c+1>=a)){
            System.out.println("Yes");
        }
        else
            System.out.println("No");
    }

}


Measured memory_bytes: 47964
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let k: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = 0f64;
    for i in 1..n + 1 {
        let mut j = 0;
        let mut s = 1;
        while s * i < k {
            s *= 2;
            j += 1;
        }
        ans += 1.0 / (f64::from(1 << j) * f64::from(n));
    }
    println!("{:.12}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>P(N);
  for(int i=0;i<N;i++)
    cin>>P.at(i);
  vector<int>Q(N);
  for(int i=0;i<N;i++)
    cin>>Q.at(i);
  vector<int>vec(N);
  for(int i=0;i<N;i++)
    vec.at(i)=(1+i);
  int a=0;
  do{
  a++;
    bool x=true;
    for(int i=0;i<N;i++){
    if(P.at(i)!=vec.at(i)){
    x=false; break;
    }
    
    } if(x)break;
  }while(next_permutation(vec.begin(),vec.end()));
  sort(vec.begin(),vec.end());
   int b=0;
  do{
  b++;
    bool x=true;
    for(int i=0;i<N;i++){
    if(Q.at(i)!=vec.at(i)){
    x=false; break;
    }
    
    } if(x)break;
  }while(next_permutation(vec.begin(),vec.end()));
         int ans=abs(a-b);
         cout<<ans<<endl;
         return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	a := make([][]byte, h)
	ys := make([]bool, h)
	xs := make([]bool, w)
	for i := 0; i < h; i++ {
		var s string
		fmt.Scan(&s)
		a[i] = make([]byte, w)
		for j := 0; j < w; j++ {
			a[i][j] = s[j]
			if s[j] == '#' {
				ys[i] = true
				xs[j] = true
			}
		}
	}
	for i := 0; i < h; i++ {
		if ys[i] {
			for j := 0; j < w; j++ {
				if xs[j] {
					fmt.Printf("%c", a[i][j])
				}
			}
			fmt.Println()
		}
	}
}


Measured memory_bytes: 512
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
even = [v[i] for i in range(n) if i % 2 == 0]
odd = [v[i] for i in range(n) if i % 2 == 1]

ecnt = Counter(even).most_common() + [(0, 0)]
ocnt = Counter(odd).most_common() + [(0, 0)]
if ecnt[0][0] == ocnt[0][0]:
    print(n - max(ecnt[0][1] + ocnt[1][1], ecnt[1][1] + ocnt[0][1]))
else:
    print(n - ecnt[0][1] - ocnt[0][1])


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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> vec(N+1, false);
    for(int k=0; k<K; k++) {
        int d;
        cin >> d;
        int A;
        for(int i=0; i<d; i++) {
            cin >> A;
            vec[A]=true;
        }
    }
    
    int ans=0;
    for(int i=1; i<vec.size(); i++) {
        if(!vec[i]) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>


int main()
{
	char inputS[99];
	int inputLength;

	scanf("%s", &inputS);
	inputLength = strlen(inputS);

	if (inputLength % 2 > 0)
	{
		for (int i = 0; i < inputLength / 2; i++)
		{
			if (inputS[i] != inputS[inputLength / 2 + i + 1])
			{
				printf("No \n");
				return 0;
			}
		}
	}
	else
	{
		for (int i = 0; i < inputLength / 2; i++)
		{
			if (inputS[i] != inputS[inputLength / 2 + i])
			{
				printf("No \n");
				return 0;
			}
		}
	}

	printf("Yes \n");

	return 0;
}

Measured memory_bytes: 128
n = int(input())

def q(x):
    print(x)
    s = str(input())
    if s == 'Vacant':
        exit()
    else:
        return s

y = q(0)
q(n-1)

def ok(x):
    if x%2 == 0:
        if y == q(x):
            return False
        else:
            return True
    else:
        if y != q(x):
            return False
        else:
            return True

l = 0
r = n-1
while l+1 < r:
    c =(l+r)//2
    if ok(c):
        r = c
    else:
        l = c
print(r)

Measured memory_bytes: 38852
n = int(input())
n1 = n - n // 10 * 10
if n1 == 0:
    print("pon")
elif n == 1:
    print("pon")
elif n1 == 2:
    print("hon")
elif n1 == 3:
    print("bon")
elif n1 == 4:
    print("hon")
elif n1 == 5:
    print("hon")
elif n1 == 6:
    print("pon")
elif n1 == 7:
    print("hon")
elif n1 == 8:
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n, Y, a = -1, b = -1, c = -1;
	cin >> n >> Y;

	eFOR(x, n) {
		eFOR(y, n) {
			if (x + y <= n && x * 10000 + y * 5000 + (n - x - y) * 1000 == Y) {

				a = x;
				b = y;
				c = n - x - y;
				goto END;
			}
		}
	}

END:

	cout << a << " " << b << " " << c << endl;


	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            if (x == 3 || x == 5 || x == 7) Console.WriteLine("YES");

            else Console.WriteLine("NO");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    char s[51][51] = {};
    rep(i,0,H){
        string tmp;
        cin >> tmp;
        rep(j,0,W){
            s[i][j] = tmp[j];
        }
    }
    int count[51][51] = {0};
    rep(i,0,H){
        rep(j,0,W){
            count[i][j] = -1;
        }
    }
    int load = 0;
    int wall = 0;
    rep(i,0,H){
        rep(j,0,W){
            if(s[i][j] == '.'){
                load++;
            }else{
                wall++;
            }
        }
    }
    // rep(i,0,H){
    //     printa(count[i]);
    // }

    queue<P> q;
    P start = {0,0};
    count[0][0] = 0;
    q.push(start);
    P before = {-1, -1};
    while(1){
        if(count[H-1][W-1] != -1 || q.empty()) break;
        P p = q.front();
        q.pop();

        if(p.x+1<W && count[p.y][p.x+1] == -1 && s[p.y][p.x+1] != '#'){
            P pt = {p.x+1, p.y};
            count[p.y][p.x+1] = count[p.y][p.x] + 1;
            q.push(pt);
        }
        if(p.x-1>=0 && count[p.y][p.x-1] == -1 && s[p.y][p.x-1] != '#'){
            P pt = {p.x-1, p.y};
            count[p.y][p.x-1] = count[p.y][p.x] + 1;
            q.push(pt);
        }
        if(p.y+1<H && count[p.y+1][p.x] == -1 && s[p.y+1][p.x] != '#'){
            P pt = {p.x, p.y+1};
            count[p.y+1][p.x] = count[p.y][p.x] + 1;
            q.push(pt);
        }
        if(p.y-1>=0 && count[p.y-1][p.x] == -1 && s[p.y-1][p.x] != '#'){
            P pt = {p.x, p.y-1};
            count[p.y-1][p.x] = count[p.y][p.x] + 1;
            q.push(pt);
        }
    }
    int ans = load - count[H-1][W-1] - 1;
    if(count[H-1][W-1] == -1){
        print(-1);
    }else{
        print(ans); 
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, x;
    cin >> n >> x;
    vi V(n), V2;
    for (int i = 0; i < n; ++i) {
        cin >> V[i];
    }
    V2 = V;
    ll ans = 0;
    for (int i = 1; i < n; ++i) {
        ll change = max(0LL, V[i]+V[i-1]-x);
        V[i] -= change;
        if (V[i] < 0) V[i] = 0;
        ans += change;
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{
	string a;
	cin >> a;
	int ans = 0;
	string lt = "";
	for (int i = 0; i < a.length(); ++i)
	{
		if (lt.length() == 1 && lt[0] == a[i])
		{
			if (i + 1 == a.length())
				break;
			lt = "";
			lt += a[i];
			lt += a[i + 1];
			++i;
			++ans;
		}
		else
		{
			lt = a[i];
			++ans;
		}
	}
	cout << ans << endl;

	char I;
	cin >> I;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for s in range(N):
    ### Step1
    S = []  # 累積和S. ただし, 初項は0ではなく1回目の移動後の得点とする.
    # 1回目の移動
    i = P[s] - 1
    S.append(C[i])
    # 2回目以降の移動. スタート地点に戻ってくるまで繰り返し.
    while i != s:
        i = P[i] - 1
        S.append(S[-1] + C[i])

    ### Step2: KとSの長に応じて場合分けして, 得点の最大値を求める.
    # 1周未満しか移動できない場合:
    if K <= len(S):
        score = max(S[:K])
    # 1周以上回ることができるが, ループを1周したときに得点が減る場合:
    elif S[-1] <= 0:
        score = max(S)
    # 1週以上回ることができ, かつループを1週するごとに得点が増える場合:
    else:
        # ループを (K // len(S) - 1)回 廻る場合:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        # ループを (K // len(S))回 廻る場合:
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        # score1 と score2 の大きい方がこの場合の得点の最大値
        score = max(score1, score2)

    ans = max(ans, score)

print(ans)

Measured memory_bytes: 79008
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = (int)S.size();
    int ans = 1000;
    for(int i = 0; i < N - 2; i++){
        int t = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
        ans = min(ans, abs(t - 753));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

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

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	int h,n; cin >> h >> n;
    vector < pair <int,int> > v;
    REP(i,n)
    {
        int tmp1 , tmp2;
        cin >> tmp1 >> tmp2;
        v.push_back(make_pair(tmp1 , tmp2));
    }

    int r[h+1];
    REP(i,h+1)
    {
        r[i] = INT_MAX;
    }
    r[0] = 0;
    
    for(int i = 1 ; i<= h ; i++)
    {
        for(int j = 0 ; j < n ; j++)
        {
            r[i] = min( r[i] , r[max(i-v[j].first , 0)] + v[j].second);
        }
    }
    
    cout << r[h] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> v(n);
	
	for (auto&& e : v) {
		cin >> e;
	}
	
	sort(v.begin(), v.end());
	cout << (v[n - 1] - v[0] ) << endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
	int n,m;
	ll ans=0;
	cin>>n>>m;
	priority_queue<int>que;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		que.push(x);
	}
	for(int i=0;i<m;i++)
	{
		que.push(que.top()/2);
		que.pop();
	}
	while(!que.empty())
	{
		ans+=que.top();
		que.pop();
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 892
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let h: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut dp: Vec<i64> = (0..n).map(|_| 0).collect();

    for i in 1..n {
        dp[i] = dp[i - 1] + (h[i] - h[i - 1]).abs();
        if i > 1 {
            dp[i] = std::cmp::min(dp[i], dp[i - 2] + (h[i] - h[i - 2]).abs());
        }
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 6396
n,a,b = map(int,input().split())
s = input()
ga = 0
gb = 0
for i in s:
    if i == 'a':
        if ga >= a+b:
            print('No')
        else:
            print('Yes')
            ga += 1
    elif i == 'b':
        if ga >= a+b or gb >= b:
            print('No')
        else:
            print('Yes')
            ga += 1
            gb += 1
    else:
        print('No')


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int a[100003][3];int n;ll dp[100003][3];
ll solve(int idx,int last)
{
  if(idx>=n)
    return 0;
  if(dp[idx][last]!=-1)
    return dp[idx][last];
  if(last==0)
    return dp[idx][last]=max(a[idx][1]+solve(idx+1,1),a[idx][2]+solve(idx+1,2));
  else if(last==1)
    return dp[idx][last]=max(a[idx][0]+solve(idx+1,0),a[idx][2]+solve(idx+1,2));
  if(last==2)
     return dp[idx][last]=max(a[idx][1]+solve(idx+1,1),a[idx][0]+solve(idx+1,0));
}
int main()
{
  
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  memset(dp,-1,sizeof(dp));
  ll ans=max(a[0][0]+solve(1,0),max(a[0][1]+solve(1,1),a[0][2]+solve(1,2)));
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 8448
import java.io.*;
        import java.util.*;
        public class Main{
          public static void main(String[] args) throws IOException{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String s = reader.readLine();
            Stack<String> stack = new Stack<String>();
            for(int i=0;i<s.length();i++){
              if(s.charAt(i)=='0'){
                stack.push("0");}
              if(s.charAt(i)=='1'){
                stack.push("1");}
              if(s.charAt(i)=='B' && !stack.isEmpty()){
                stack.pop();}}
            String res = "";
            while(!stack.isEmpty()){
                String p = stack.pop();
              res = p+res;}
            System.out.println(res);}}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> p;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<std::vector<int>> hp(n, std::vector<int>(2, 0));
    for (int i = 0; i < n; i++) {
        cin >> hp[i][0] >> hp[i][1];
    }

    std::sort(hp.begin(), hp.end(),
        [](const std::vector<int>& a, const std::vector<int>& b) {
            return a[0] + a[1] < b[0] + b[1];
        });
    std::vector<std::vector<int>> dp(n + 1, std::vector<int>(n + 1, INF));
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            int a = INF;
            if (dp[i - 1][j - 1] <= hp[i - 1][0]) {
                a = dp[i - 1][j - 1] + hp[i - 1][1];
            }
            dp[i][j] = min(dp[i - 1][j], a);
        }
    }
    int out = 0;
    for (int i = n; i >= 0; i--) {
        if (dp[n][i] != INF) {
            out = i;
            break;
        }
    }
    cout << out << endl;

    return 0;
}

Measured memory_bytes: 196224
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 19 22:51:44 2018

@author: maezawa
"""

class node():
    def __init__(self, key, parent=None, right=None, left=None):
        self.key = key
        self.parent = parent
        self.right = right
        self.left = left
        
def insert(z):
    global root
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    
    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z  
    #inorder(root)
    
        
def inorder(u):
    if u == None:
        return
    inorder(u.left)
    print(' {}'.format(u.key), end = '')
    inorder(u.right)
    
def preorder(u):
    if u == None:
        return
    print(' {}'.format(u.key), end = '')
    preorder(u.left)
    preorder(u.right)
    
root = None

n = int(input())
for i in range(n):
    q = list(input().split())
    if q[0] == 'insert':
        z = node(int(q[1]))
        insert(z)
    elif q[0] == 'print':
        inorder(root)
        print()
        preorder(root)
        print()
        
        


Measured memory_bytes: 105012
N, T = map(int, input().split())
ct = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
# print(ct)

for i in range(N):
    if ct[i][1] <= T:
        print(ct[i][0])
        break
    else:
        if i == N - 1:
            print('TLE')


Measured memory_bytes: 3060
s = str(raw_input())
p = str(raw_input())

i = 0
while(1):
    if i == len(s):
        print "No"
        break
    if i+len(p) >= len(s):
        str = s[i:len(s)] + s[0:len(p)-len(s[i:len(s)])]
    else:
        str = s[i:i+len(p)]
    if str == p:
        print "Yes"
        break
    else:
        i += 1

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

#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
int n,w,k;
map<int, vector<int> > m;

int dfs(int p, int d, int s)
{
	int sum=s;
	//cout << p << "\n";
	for(int i=d;i<=k+3;++i)
	{
		if(p+i>w)
			break;
		if(m[i].size()>0)
		{
			int bb=m[i][m[i].size()-1];
			m[i].pop_back();
			sum=max(sum,dfs(p+i,i,s+bb));
			m[i].pb(bb);
		}
	}
	return sum;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	cin >> n >> w;
	for(int i=1;i<=n;++i)
	{
		int a,b;
		cin >> a >> b;
		m[a].pb(b);
		if(i==1)
			k=a;
	}
	for(int i=k;i<=k+3;++i)
	{
		if(m[i].size()>0)
			sort(m[i].begin(),m[i].end());
	}
	cout << dfs(0,k,0);
	return 0;
}

Measured memory_bytes: 256
import java.util.Stack;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Stack<String> stack = new Stack<>();
		
		String input = in.nextLine();
		String[] tokens = input.split(" ");
		
		for (String n : tokens) {
			int o1, o2;
			
			String[] operations = {"+", "-", "*", "/"};
			boolean op = false;
			
			for (String operation : operations) {
				if (n.equals(operation)) {
					op = true;
				}
			}
			
			if (op) {
				o1 = Integer.parseInt(stack.pop());
				o2 = Integer.parseInt(stack.pop());
				
				switch (n) {
					case "+":
						stack.push("" + (o2 + o1));
						break;
					case "-":
						stack.push("" + (o2 - o1));
						break;
					case "*":
						stack.push("" + (o2 * o1));
						break;
					case "/":
						stack.push("" + (o2 / o1));
						break;
					case "%":
						stack.push("" + (o2 % o1));
						break;
				}
			} else {
				stack.push(n);
			}
		}
		
		System.out.println(stack.pop());
	}
}


Measured memory_bytes: 26128
#include <iostream>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int H, W;
vector<string> tiles;
bool reached[110][110];

int main() {
	while (1) {
		cin >> H >> W; if (H == 0 && W == 0) break;
		
		tiles.assign(H, "");
		for (int i = 0; i < H; i++) {
			cin >> tiles[i];
		}
		
		memset(reached, 0, sizeof(reached));
		
		int x = 0, y = 0;
		bool loop = false;
		while (tiles[y][x] != '.') {
			if (reached[y][x]) {
				loop = true;
				break;
			}
			reached[y][x] = true;
			char t = tiles[y][x];
			
			if (t == '>') {
				x++;
			}
			if (t == '<') {
				x--;
			}
			if (t == '^') {
				y--;
			}
			if (t == 'v') {
				y++;
			}
		}
		
		if (loop) cout << "LOOP" << endl;
		else cout << x << " " << y << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1260
N,K = gets.split(' ').map(&:to_i)
R,S,P = gets.split(' ').map(&:to_i)
T = gets

arrays = Array.new
K.times do
  arrays << Array.new
end

i = 0
N.times do
  arrays[i%K].push(T[i])
  i += 1
end

score = 0
arrays.each do |arr|
  arr.size.times do |i|
    if i!=0 and arr[i]==arr[i-1]
      arr[i]='x'
    else
      if arr[i]=='r'
        score += P
      elsif arr[i]=='s'
        score += R
      else
        score += S
      end
    end
  end
end

print score

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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s;
  cin>>s;
  int n=s.size();
  if(n&1){
    cout<<"No"<<'\n';
    return 0;
  }
  REP(i, n/2){
    if(s[i*2]!='h' || s[i*2+1]!='i'){
      cout<<"No"<<'\n';
      return 0;
    }
  }
  cout<<"Yes"<<'\n';
  return 0;
}


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

bool CanBeMonth(int s) {
  return 1 <= s && s <= 12;
}

int main() {
  int s;
  cin >> s;
  bool is_yymm = CanBeMonth(s % 100);
  bool is_mmyy = CanBeMonth(s / 100);
  if (is_yymm) {
    cout << (is_mmyy ? "AMBIGUOUS\n" : "YYMM\n");
  } else {
    cout << (is_mmyy ? "MMYY\n" : "NA\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
int S[1 << 20];
vector<int> slime;

void solve(){
    cin >> n;
    rep(i,1<<n){
        cin >> S[i];
    }
    sort(S,S+(1<<n),greater<int>());
    slime.push_back(S[0]);
    multiset<int> s;
    Rep(i,1,1<<n){
        s.insert(S[i]);
    }
    rep(i,n){
        rep(k,1<<i){
            //cout << i << " " << slime[k] << endl;
            auto m=s.lower_bound(slime[k]);
            if (m!=s.begin()){
                m--;
                slime.push_back(*m);
                //cout << *m << endl;
                s.erase(m);
            }
            else{
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 13568
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

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

int main()
{
	ll n;
	scanf("%lld", &n);
	ll a[200001];
	for(ll i=1; i<=n; i++){
		scanf("%lld", &a[i]);
		a[i]-=i;
	}
	sort(a+1, a+n+1);
	ll s[200001];
	s[0]=0;
	for(ll i=1; i<=n; i++){
		s[i]=s[i-1]+a[i];
	}
	ll ans=1e18;
	for(ll i=1; i<=n; i++){
		ll ans1=a[i]*(i-1)-s[i-1]+s[n]-s[i]-a[i]*(n-i);
		if(ans>ans1) ans=ans1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int tmp;
  int ans =0;
  for(int i=1; i<=n; i++){
    tmp = to_string(i).size();
    if(tmp%2==1)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  ll a,b,c,d; cin >>a >>b >>c >>d;
  if(a>=0&&c>=0) cout <<b*d;
  else if(b<=0&&d<=0) cout <<a*c;
  else if(a>=0&&d<=0) cout <<a*d;
  else if(c>=0&&b<=0) cout <<b*c;
  else cout <<max(a*c,b*d);
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long   

const ll mod=1e9+7;


int main ()
{
    int N , C [500] , S [500] , F [500];
    cin>>N;
for ( int i =0; i <N -1; i ++) 
cin>>C[i]>>S[i]>>F[i];
for ( int i =0; i < N ; i ++)
{
int t =0;
for ( int j = i ;j <N -1; j ++)
{
  if (t < S [ j ]) t = S [ j ];
   else if ( t % F [ j ]==0);
   else t = t + F [ j ] - t % F [ j ];
  t += C [ j ];
}
 cout<<t<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=35,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int in[MAXn],out[MAXn];
int main(){
  IOS();
  string s,t;
  cin>>s>>t;
  int n = SZ(s);
  RST(out,-1);
  REP(i,n){
    int ss = s[i]-'a', tt = t[i]-'a';
    debug(ss,tt);
    if( out[ss]!=-1 && out[ss]!=tt ) return cout<<"No"<<endl,0;
    if( out[ss]==tt ) continue;
    if( in[tt] ) return cout<<"No"<<endl,0;
    out[ss] = tt;
    in[tt]++;
  }
  cout<<"Yes"<<endl;
}


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

using namespace std;


const int maxn=100+10;
char s[maxn][maxn];
int dp[maxn][maxn][2];
int h,w;
int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
        for(int j=0;j<w;j++)dp[i][j][0]=dp[i][j][1]=300;
        for(int j=0;j<w;j++){
            if(s[i][j]=='.')s[i][j]=0;
            else s[i][j]=1;
        }
    }
    if(s[0][0]==1){
        dp[0][0][1]=1;
    }
    else {
        dp[0][0][0]=0;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0&&j==0)continue;
            if(i>0){
                if(s[i][j]!=s[i-1][j]&&s[i][j]==1){
                    dp[i][j][s[i][j]]=min(dp[i][j][s[i][j]],dp[i-1][j][s[i-1][j]]+1);
                }
                else{
                    dp[i][j][s[i][j]]=min(dp[i][j][s[i][j]],dp[i-1][j][s[i-1][j]]);
                }
            }
            if(j>0){
                if(s[i][j]!=s[i][j-1]&&s[i][j]==1){
                    dp[i][j][s[i][j]]=min(dp[i][j][s[i][j]],dp[i][j-1][s[i][j-1]]+1);
                }
                else{
                    dp[i][j][s[i][j]]=min(dp[i][j][s[i][j]],dp[i][j-1][s[i][j-1]]);
                }
            }
        }
    }
    cout<<dp[h-1][w-1][s[h-1][w-1]]<<endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
C = list(input())
# print(n)
# print(C)
l = 0
r = n-1
c = 0
while l < r:
    # print('l {} r {}'.format(l,r))
    # print('C[l] {} C[r] {}'.format(C[l],C[r]))

    if C[l]=='W' and C[r]=='R':
        C[l],C[r] = C[r],C[l]
        l += 1
        r -= 1
        c += 1
        # print('C {}'.format(C))

    elif C[l]!='W':
        l += 1
    elif C[r]!='R':
        r -= 1

print(c)


Measured memory_bytes: 10784
#include<stdio.h>
int main(void){
	int N,i=0,n=-1,sign=1;
	int A[200];
	for(scanf("%d",&N);i<N;scanf("%d",&A[i++]));
	while(sign){
		for(i=0; i<N; i++){
			if(A[i]%2){sign=0;break;}
			A[i]/=2;
		}
		n++;
	}
	printf("%d\n",n);
}

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

int main() {
  int h, w;
  cin >> h >> w;
  string a[50];

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

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '.') {
        int x = 0;
        for (int k = i - 1; k <= i + 1; k++) {
          for (int l = j - 1; l <= j + 1; l++) {
            if ((k < 0) or (j < 0) or (k >= h) or (l >= w)) {
              continue;
            }
            if (a[k][l] == '#') {
              x++;
            }
          }
        }
        a[i][j] = char('0' + x);
      }
    }
  }
  for (int i = 0; i < h; i++) {
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> a >> b;
	if (a * b % 2 == 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl


int main(){
	
	ios::sync_with_stdio(false);
	ll N;
	cin>>N;
	vector<ll> arr(N);
	REP(i,N)cin>>arr[i];
	ll sell_count = 0;	
	sell_count = arr[0] - 1;
	ll P = 2;	
	for(ll i = 1; i < N; i++ ){
		
		if(arr[i] == P){
			P++;
			continue;
		}
	
		ll s_c = arr[i] / P;
		if(arr[i] % P == 0){
			s_c -= 1;
		}
		sell_count += s_c;
	}

	cout<<sell_count<<endl;
	
	return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

bool is_setwise_coprime(const vector<int>& A) {
    int N = A.size();
    int g = A[0];
    for_(i,1,N) g = __gcd(g, A[i]);
    return g == 1;
}

bool is_pairwise_coprime(const vector<int>& A) {
    const int MXP = 1000006;
    vector<bool> is_prime(MXP, true);
    vector<int > prev_prime(MXP, -1);
    for_(i,2,MXP) {
        if (is_prime[i]) {
            for (int j=2*i; j<MXP; j+=i) {
                is_prime[j] = false;
                prev_prime[j] = i;
            }
        }
    }

    vector<int> count(MXP, 0);
    int N = A.size();
    for_(i,0,N) {
        int X = A[i];
        while (prev_prime[X] != -1) {
            int p = prev_prime[X];
            while (X % p == 0) X /= p;
            ++count[p];
        }
        if (X == 1) continue;
        ++count[X];
    }

    return (*max_element(ALL(count)) <= 1);
}

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

    vector<int> A(N);
    for_(i,0,N) cin >> A[i];

    if (is_setwise_coprime(A)) {
        if (is_pairwise_coprime(A)) {
            puts("pairwise coprime");
        }
        else {
            puts("setwise coprime");
        }
    }
    else {
        puts("not coprime");
    }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x,  k;
string s, t;

// <------------- Implement Functions Here ----------> //

queue<ll> q[2000];
ll m[2000][2000] = {};
queue<ll> q1,q2;

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> x;
	cout<<(ld)((ld)(n)/(x));
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 5152
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
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;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[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()),*)
    }};
}

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn a() {
    unimplemented!();
}

fn b() {
    unimplemented!();
}

fn c() {
    let n = read!(usize);
    if n == 2 {
        println!("1");
        return;
    }
    if n == 3 || n == 4 {
        println!("2");
        return;
    }
    let mut max_div = 1;
    for i in 1..((n as f64).sqrt() as usize + 1) {
        //        println!("{}", i);
        if n % i == 0 {
            max_div = i;
        }
    }
    let t = n / max_div;

    //    debugln!("{} {}", max_div, t);

    println!("{}", max_div + t - 2);
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    c();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = (1e+9)+7;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
int main()
{
  ll n,k,x[200000],y[200000];
  cin >> n >> k;
  rep(i,n)cin >> x[i];
  rep(i,n-k+1){if(x[i]<0&&x[i+k-1]<0)y[i]=abs(x[i]);
             else if(x[i]<0)y[i]=abs(min(-x[i],x[i+k-1])-x[i]+x[i+k-1]);
           else y[i]=abs(x[i+k-1]);
          }
  sort(y,y+n-k+1);
  printf("%lld",abs(y[0]));
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

int main() {
    string S;
    cin >> S;
    int n = S.size();
    if (S[n-1] == '3') {
        cout << "bon" << endl;
    } else if (S[n-1] == '0' || S[n-1] == '1' || S[n-1] == '6' || S[n-1] == '8') {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3632
unittest
{
	assert( [ "4 2", "1 3", "2 3" ].parse.expand.solve == "YES" );
	assert( [ "3 2", "2 4", "1 2" ].parse.expand.solve == "NO" );
	assert( [ "2 1", "3 2", "4 3" ].parse.expand.solve == "YES" );
	
	assert( [ "1 2", "2 3", "3 1" ].parse.expand.solve == "NO" );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abs = new long[ 2 ][ 3 ];
	foreach( ref ab; abs )
	{
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
		input.popFront;
	}
	return tuple( abs );
}

auto solve( long[ 2 ][] abs )
{
	auto cs = new long[ 4 ];
	foreach( ab; abs )
	{
		cs[ ab[ 0 ] ]++;
		cs[ ab[ 1 ] ]++;
	}
	return ( cs.filter!( ( c ) => c < 1 || 2 < c ).empty ) ? "YES" : "NO";
}


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

int main() {
  int c,a,b;
  cin >>c>>a>>b;
  if ((b-a)%2==0) {
    cout << "Alice" << endl;
  }
   else if((b-a)%2==1){
  cout << "Borys" << endl;
   }
  else
    cout<<"Draw"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, n;
    int a[100];
    
    scanf("%d", &n);
    
    for(i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    
    for(i = n - 1; i >= 0; --i){
        printf("%d", a[i]);
        
        if(i > 0){
            putchar(' ');
        }
    }
    
    putchar('\n');
    
    return 0;
}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
ll c[4004] , a[4004];
ll rev[2][4004];
ll dp[2002][2002];
ll sum[2][4010][2004];
const ll INF = 1e16;
ll solve(ll i , ll j)
{
        if(i < 0 || j < 0) return INF;
        if(i == 0 && j == 0) return 0;
        if(dp[i][j] != -1) return dp[i][j];
        ll ret = INF;
        ret = solve(i-1 , j) + sum[0][rev[0][i] + 1][i-1] + sum[1][rev[0][i] + 1][j];
        ll op = solve(i , j-1) + sum[1][rev[1][j] + 1][j-1] + sum[0][rev[1][j] + 1][i];
        ret = min(ret , op);
        return dp[i][j] = ret;
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cin >> n;
        for(ll i=1;i<=n+n;i++) {

                char x;
                cin >> x >> a[i];
                c[i] = (x == 'B');
                rev[c[i]][a[i]] = i;
                for(ll j = a[i] ; j <= n; j++) {
                        sum[c[i]][i][j]++;
                }
        }
        for(ll i=0;i<=1;i++) {
                for(ll j = n+n;j >= 1 ; j--) {
                        for(ll k=1;k<=n;k++) {
                                sum[i][j][k] += sum[i][j+1][k];
                        }
                }
        }
        memset(dp,-1,sizeof dp);
        cout << solve(n , n) << endl;
        return 0;
}


Measured memory_bytes: 157440