akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    bool alp[26];
    
    sort(s.begin(), s.end());
    int len = s.size();
    
    rep(i, 26)   alp[i] = true;
    
    int tmp;
    rep(i, len){
        tmp = s[i] - 'a';
        alp[tmp] = false;
    }
    
    char output;
    rep(i, 26){
        if(alp[i]){
            output = i + 'a';
            cout << output << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    
    return 0;
}

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

int main() {
	int nums[3];
	for (int i = 0; i < 3; i++){
		cin >> nums[i];
	}
	sort(nums, nums + 3);

	int ret = nums[2] * 10 + nums[1] + nums[0];
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll; 
typedef pair<int,int > pp;
 
 
#define sz(x) (int)x.size() 
#define PI acos(-1)
int const N=1e5+10;
int  oo = 1e9;
int mod = oo+7;
ll OO = 3e18;
 
 
ll k;
void solve(){
	cin>>k;
	ll an=OO;
	for(ll i=1;i*i<=k;i++){
		if(k%i)continue;
		an=min(an,k/i+i-2);
	}
	cout<<an<<'\n';
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	t=1;
	while(t--)solve();
	
	return 0;
}


Measured memory_bytes: 256
table = list(map(int, input()))
diff_nagomi = 1000
ans = 0
for i in range(len(table)-2):
    diff = abs(table[i] * 100 + table[i + 1] * 10 + table[i + 2] - 753)
    if diff_nagomi > diff:
        ans = diff
        diff_nagomi = diff
print(ans)


Measured memory_bytes: 8932
#include<bits/stdc++.h>
using namespace std;
int n,g,p,w,r,i;
string s,t;
int main(){
	cin>>n>>s;
	for(i=0;i<n;i++)s[i]=='W'?p++:g++;
	for(i=0;i<g;i++)t+="R";
	for(i=0;i<p;i++)t+="W";
	for(i=0;i<n;i++){
		if(s[i]=='R'&&t[i]=='W')r++;
		else if(s[i]=='W'&&t[i]=='R')w++;
	}
	cout<<min(w,r)+abs(w-r);
	return 0;
}

Measured memory_bytes: 3872
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){   
    long double r;
    cin >> r;
    long double ans = 2.0 * 3.14159265359 * r;
    cout << ans;
}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("../../input", "r", stdin);
                                                            // freopen("../../output", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif


    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}

Measured memory_bytes: 3812
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();
        
        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    // 内部→9回裏返される→裏
    // 辺→6回裏返される→表
    // 角→4回裏返される→表
    // 裏の枚数＝内部の枚数＝(N-2)*(M-2)
    let (n, m) = read_cols!(u64, u64);

    let ans = if n == 1 {
        if m == 1 {
            1
        } else {
            // 端以外→3回→裏
            // 端→2回→表
            // 裏の枚数=m-2
            m - 2
        }
    } else {
        if m == 1 {
            n - 2
        } else {
            (n - 2) * (m - 2)
        }
    };

    println!("{}", ans);
}

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

int main() {
  int N; string S;
  cin >> N >> S;
  int cnt=0;
  for (auto i:S) {
    if (i=='(') cnt++;
    else {
      cnt--;
      if (cnt<0) {
        cout << '(';
        cnt++;
      }
    }
    // cout << i;
  }
  cout << S;
  // rep(i,cnt) cout << ')';
  cout << string(cnt,')') <<endl;
} 

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 1010, M = 1000010;

int n, m;
int g[N][N];
int h[M], e[M], ne[M], idx;
int q[M], d[M], f[M];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int top_sort(int st)
{
	int hh = 0, tt = -1;
	q[ ++ tt] = st;
	f[st] = 0;
			
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			
			if ( -- d[j] == 0)
			{
				f[j] = f[t] + 1;
				q[ ++ tt] = j;
			}
		}
	}
	
	int res = 0;
	for (int i = 1; i <= m; i ++ )
		if (!f[i]) return -1;
		else res = max(res, f[i]);
	return res;
}

int main()
{
	memset(h, -1, sizeof h);
	cin >> n;
	for (int i = 1; i <= n; i ++ )
		for (int j = i + 1; j <= n; j ++ )
			g[i][j] = g[j][i] = ++ m;
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 0, a = m + 1; j < n - 1; j ++ )
		{
			int t;
			scanf("%d", &t);
			int b = g[i][t];
			add(a, b);
			d[b] ++ ;
			a = b;
		}
		
	cout << top_sort(m + 1) << endl;
    return 0;
}

Measured memory_bytes: 25168
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ull n;
	cin>>n;
	if(n%11==0){
		cout<<ull(n/11)*2<<endl;
	}else if(n%11<=6){
		cout<<ull(n/11)*2+1<<endl;
	}else{
		cout<<ull(n/11)*2+2<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100

void change(int *a, int *b) {
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}
int bubbledSort(int a[], int n)
{
	int flag = 1;
	int j;
	int cnt = 0;
	while (flag) {
		flag = 0;
		for (j = n - 1; j > 0; j--) {
			if (a[j] < a[j - 1]) {
				change(&a[j], &a[j - 1]);
				cnt++;
				flag = 1;
			}
		}
	}
	return cnt;
}

void print_a(int a[], int n) {
	int i;
	for (i = 0; i < n - 1; i++) {
		printf("%d ", a[i]);
		
	}
	printf("%d\n", a[n - 1]);
}
int main()
{
	int a[MAX], n,i,cnt;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	cnt = bubbledSort(a, n);
	print_a(a, n);
	printf("%d\n", cnt);
	return 0;

}


Measured memory_bytes: 2136
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- unfoldr (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n xs

solve :: Int -> [Int] ->  Int
solve n xs = go 0 (Q 0 0 [] []) xs
  where
    go !res q (x:xs)
        | Just q' <- enqueue x q = go res q' xs
    go res q xs
        | Just q' <- snd <$> dequeue q = go (res + size q) q' xs
        | otherwise = res

data Q = Q !Int !Int [Int] [Int] deriving Show

size :: Q -> Int
size (Q _ l _ _) = l

enqueue :: Int -> Q -> Maybe Q
enqueue x (Q set l fs rs)
    | x .&. set == 0 = Just $ Q (set .|. x) (l + 1) fs (x:rs)
    | otherwise = Nothing

dequeue :: Q -> Maybe (Int, Q)
dequeue (Q _ 0 _ _)     = Nothing
dequeue (Q set l [] rs) = dequeue (Q set l (reverse rs) [])
dequeue (Q set l (f:fs) rs) = case Q (set `xor` f) (l - 1) fs rs of
    q -> Just (f, q)


Measured memory_bytes: 15484
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a, b, c, d, e, f, N, M;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a;
	switch (a % 10)
	{
	case 3:
		cout << "bon";
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon";
		break;
	default:
		cout << "hon";
	}
}

Measured memory_bytes: 3692
using System;
using System.Collections.Generic;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var strABCD = input.Select(c=>c.ToString()).ToList();

            var opList = new List<List<string>>()
            {
                new List<string>(){ "+", "+", "+" },
                new List<string>(){ "+", "+", "-" },
                new List<string>(){ "+", "-", "+" },
                new List<string>(){ "+", "-", "-" },
                new List<string>(){ "-", "+", "+" },
                new List<string>(){ "-", "+", "-" },
                new List<string>(){ "-", "-", "+" },
                new List<string>(){ "-", "-", "-" },
            };

            Func<string, int> Calc = (str) =>
             {
                 var ans = int.Parse(str[0].ToString());
                 for(int i = 2;i<str.Length;i++)
                 {
                     if (str[i-1] == '-'|| str[i - 1] == '+')
                     {
                         ans += int.Parse(str[i - 1].ToString() + str[i].ToString());
                     }
                 }
                 return ans;
             };

            foreach (var item in opList)
            {
                var tmpAnswer = strABCD[0] + item[0] + strABCD[1] + item[1] + strABCD[2] + item[2] + strABCD[3];
                var result = Calc(tmpAnswer);
                if (int.Parse(result.ToString()) != 7) continue;
                Console.WriteLine(tmpAnswer + "=7");
                return;
            }

        }
    }

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

#define loop(n) for(int ind=0;ind<n;ind++)
int main(){
    int n,k;
    cin>>n>>k;
    int heights[n], min_cost[n]={0};
    loop(n) cin>>heights[ind];
    for(int ind=1; ind<n; ind++){
        int min_for_ind = INT_MAX;
        for(int step=1;step<=k;step++){
            if(ind-step >= 0){
                int cost_with_step = min_cost[ind-step] + abs(heights[ind]-heights[ind-step]);
                min_for_ind = min(min_for_ind, cost_with_step);
            }
        }
        min_cost[ind] = min_for_ind;
    }
    cout<<min_cost[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <algorithm>

using namespace std;

int main(void){
  int n, m, ans=0;
  cin >> n >> m;
  int l[m], r[m];

  for(int i=0; i<m; ++i)
    scanf("%d %d", &l[i], &r[i]);

  if(*min_element(r, r+m) - *max_element(l, l+m) + 1 >= 0)
    ans = *min_element(r, r+m) - *max_element(l, l+m) + 1;

  cout <<  ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int N,M;
  int i;
  int A[1010];
  int s=0;
  
  scanf("%d %d",&N,&M);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    s=s+A[i];
  }
  double S=s/4.0/M;
  int j=0;
  for(i=0;i<N;i++){
    if(A[i]>=S){
      j=j+1;
    }
  }
  if(j>=M){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1624
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 2000;
const int INF = (1<<30);
struct edge{
	int to; edge *nxt;
}edges[2*MAXN + 5], *adj[MAXN + 5], *ecnt=&edges[0];
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
	p = (++ecnt);
	p->to = u, p->nxt = adj[v], adj[v] = p;
}
int a[MAXN + 5], N;
int f[MAXN + 5], s[MAXN + 5];
void dfs(int x, int fa) {
	s[x] = a[x], f[x] = 0;
	for(edge *p=adj[x];p;p=p->nxt) {
		if( p->to == fa ) continue;
		dfs(p->to, x), s[x] += s[p->to];
		f[x] += f[p->to] + s[p->to];
	}
}
int get(int x, int fa) {
	int mx = 0;
	for(edge *p=adj[x];p;p=p->nxt) {
		if( p->to == fa ) continue;
		if( mx == 0 || f[p->to] > f[mx] ) mx = p->to;
	}
	if( mx == 0 ) return 0;
	int k = get(mx, x) + s[mx];
	if( f[x] - f[mx] - s[mx] >= k ) return f[x] & 1;
	else return k - (f[x] - f[mx] - s[mx]);
}
char S[MAXN + 5];
int main() {
	scanf("%d%s", &N, S + 1);
	for(int i=1;i<=N;i++) a[i] = S[i] - '0';
	for(int i=1;i<N;i++) {
		int u, v; scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	int ans = INF;
	for(int j=1;j<=N;j++) {
		dfs(j, 0);
		if( get(j, 0) == 0 )
			ans = min(ans, f[j]/2);
	}
	if( ans == INF ) printf("-1\n");
	else printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll MOD = 1e9+7;

int n;
string s;
map<char, int> mp;

int main() {
    cin >> n >> s;
    for(auto c : s)
        mp[c]++;

    ll ans = 1;
    for(auto p : mp) {
        ans *= p.second + 1;
        ans %= MOD;
    }
    cout << ans - 1 << endl;
}

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

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

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

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数

int main()
{
	int n, m;
	string s;
	cin >> n >> s;

	if (n >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

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

const ll YMAX = (1ll << 31) - 1;
vector<ll> dat;
int N;

void update(int k, int a) {
  k += N - 1;
  dat[k] += a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] += a;
  }
}

int find(int a, int b, int k, int l, int r) {
  // [a, b) での最小値。[l, r) と節点kが対応
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b) return dat[k];
  else {
    int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
    return vl + vr;
  }
}

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

  cin >> N;
  ll Q; cin >> Q;
  ll N_ = N;
  N = 1;
  while (N < N_) N *= 2;
  dat = vector<ll>(2 * N - 1, 0);

  for (ll i = 0; i < Q; i++) {
    int q; cin >> q;
    if (q == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      s--;
      update(s, x);
      if (t < N) update(t, -x);
    } else {
      int s; cin >> s;
      int ans = find(0, s, 0, 0, N);
      cout << ans << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 4852
#include<stdio.h>

int poi(int);
int w;
int main(){
	
	int a;
	int x;
	while(1){
		scanf("%d",&w);
		if(w==-1){
			break;
		}
		a=poi(x);

		printf("%d\n",4280-a);
	}
	return 0;
	
}

int poi(int a){
	int x;	
	if(w<=10){
		x=1150;
	}else if(w>=11&&w<=20){
		x=1150+(w-10)*125;
	}else if(w>=21&&w<=30){
		x=2400+(w-20)*140;
	}else{
		x=3800+(w-30)*160;
	}
	
	return x;
	
}

Measured memory_bytes: 600
k, n = map(int, input().split())
a = list(map(int, input().split()))

#N軒目から1軒目までの距離が最大の時
d1 = k - (a[0] + (k-a[n-1]))

#それ以外
d = []
for x in range(len(a)):
    y = a[x] - a[x-1]
    d.append(y)

d2 = k - max(d)
print(min(d1,d2))

Measured memory_bytes: 26436
N,X = gets.chomp.split.map(&:to_i)
min = 1e9

for i in 1..N do
    c,t = gets.chomp.split.map(&:to_i)
    if(t<=X)
        min=[min,c].min
    end
end
if(min==1e9)
    puts "TLE"
else
    puts min
end

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string ans = "ai1333";
    for(int i = 0; i < n / 100; i++) ans += '3';
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;

ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }
ll dp[101][1000006];

ll weight[101];
ll val[101];

int n;

ll f(int idx, int remWeight)
{
    //cout << idx <<" " << remWeight<<endl;
    if(idx>n)
    {
        return 0;
    }
    if(remWeight<0)
    {
        return 0;
    }
    if(dp[idx][remWeight]!=-1LL) return dp[idx][remWeight];

    ll f1=f(idx+1,remWeight);
    ll f2=0;
    if(remWeight-weight[idx]>=0)
         f2=val[idx]+f(idx+1,remWeight-weight[idx]);
    return dp[idx][remWeight]=max(f1,f2);
}

int main()
{
    mem(dp,-1LL);
    ll W;
    cin >> n >> W;
    for(int i=0;i<n;i++)
    {
        cin  >> weight[i] >> val[i];
    }
    ll res=f(0,W);
    cout << res << endl;
}


Measured memory_bytes: 789376
import sys
input = sys.stdin.readline
N = int(input())
d = [list(map(int, input().split())) for _ in range(N)]
d.sort(key = lambda x: (x[0] + x[1]))
t = 0
a = 0
for i in range(N):
  if i % 2:
    a += d.pop()[1]
  else:
    t += d.pop()[0]
print(t - a)

Measured memory_bytes: 61660
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n;
    cin >> n;
    vector<ll> x(n);
    for (ll i=0;i<n;++i){
        ll a;
        cin >> a;
        x[i]=a;
    }
    sort(x.begin(),x.end());
    cout << x[x.size()-1]-x[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a,b;
int sum;
int digit;
int main()
{
    while(cin>>a>>b)
    {
        sum = a+b;
        while(sum>0)
        {
            sum/=10;
            digit++;
        }
        cout << digit;
        cout << endl;
        digit = 0;
    }
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {

        int n = int.Parse(Console.ReadLine());

        string s = Console.ReadLine();

        string result = "No";

        if (n % 2 == 0) {
            string t1 = s.Substring(0, n / 2);
            string t2 = s.Substring(n / 2);

            if (t1 == t2) result = "Yes";
        }


        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

using cat = long long;

cat mod = 998244353;

cat pw(cat a, cat e) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2);
	x = x * x % mod;
	if(e&1) x = x * a % mod;
	return x;
}

cat om[22];

void ntt(cat * a, int n, bool rev = 0) {
	for(int i = 0, j = 0; i < n; ++i) {
		if(i < j) swap(a[i], a[j]);
		for(int k = n>>1; (j^=k) < k; k >>= 1) {}
	}
	for(int i = 2, e = 1; i <= n; i <<= 1, e++) {
		int len = i>>1;
		cat w = om[e];
		for(int j = 0; j < n; j += i) {
			cat cur = 1;
			for(int k = j; k < j+len; ++k) {
				cat u = a[k], v = a[k+len] * cur % mod;
				a[k] = u + v, a[k+len] = u - v;
				if(a[k] >= mod) a[k] -= mod;
				if(a[k+len] < 0) a[k+len] += mod;
				cur = cur * w % mod;
			}
		}
	}
	if(rev) {
		cat n_inv = pw(n, mod-2);
		reverse(a+1, a+n);
		for(int i = 0; i < n; i++) a[i] = a[i] * n_inv % mod;
	}
}

int main() {
	for(int i = 0; i < 22; i++) om[i] = pw(3, (mod-1)>>i);
	int N, M;
	cin >> N >> M;
	cat fac[500010], inv[500010];
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= 500000; i++) fac[i] = fac[i-1] * i % mod;
	for(int i = 1; i <= 500000; i++) inv[i] = (i%2 == 0 && i > 2) ? inv[2] * inv[i/2] % mod : pw(i, mod-2);
	for(int i = 1; i <= 500000; i++) inv[i] = inv[i-1] * inv[i] % mod;
	cat A[1<<20];
	memset(A, 0, sizeof(A));
	cat N_pw = 1;
	for(int i = 0; i <= M; i++) {
		A[i] = inv[i] * N_pw % mod;
		N_pw = N_pw * N % mod;
	}
	ntt(A, 1<<20);
	cat B[1<<20];
	memset(B, 0, sizeof(B));
	cat M_pw = 1;
	for(int i = N; i >= 0; i--) {
		B[i] = inv[i] * inv[N-i] % mod * M_pw % mod;
		M_pw = M_pw * (mod-1-M) % mod;
	}
	ntt(B, 1<<20);
	cat C[1<<20];
	for(int i = 0; i < (1<<20); i++) C[i] = A[i] * B[i] % mod;
	ntt(C, 1<<20, 1);
	cat ans = 0;
	for(int i = 0; i <= M; i++) ans = (ans + C[i] * inv[M-i]) % mod;
	ans = ans * fac[N] % mod * fac[M] % mod * (N%2 ? mod-1 : 1) % mod;
	cout << ans << "\n";
}


Measured memory_bytes: 32640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    auto a = abs(A - B);
    cout << (a % 2 ? "Borys" : "Alice") << endl;
    return 0;
}

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

int oceanview(int N,vector<int> H){
    int count=1;
    int i,j;
    for(i=1;i < N;i++){
        for(j=i-1;j>-1;j--){
            //cout<< i << " " << H[i] << " " << j << " " <<H[j] << endl;
            if(H[i]>=H[j]){
                continue;
            }
            else break;
        }
        if(j==-1) count++;
      // cout<< count << endl;
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    
    vector<int> H(N,0);
    for(int i=0;i<N;i++)
        cin >> H[i];
    
    cout << oceanview(N,H) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
import math

def soin(n):
    ret = 1
    for i in range(2, int(math.sqrt(n)) + 1):
        x = 0
        while n % i == 0:
            n /= i
            x += 1
        ret *= x + 1
    return 2 if ret == 1 else ret

N = int(input())

ret = 0
for i in range(1, N + 1, 2):
    if soin(i) == 8:
        ret += 1
        
print(ret)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	string A, B;
	cin >> A >> B;
	int flag;
	if (A.size() < B.size()) flag = -1;
	else if (A.size() > B.size()) flag = 1;
	else {
		flag = 0;
		for (int i = 0; i < A.size(); i++) {
			if (A[i] < B[i]) {
				flag = -1;
				break;
			}
			if (A[i] > B[i]) {
				flag = 1;
				break;
			}
		}
	}

	cout << (flag == 0 ? "EQUAL" : (flag < 0 ? "LESS" : "GREATER")) << endl;

	return 0;
}

Measured memory_bytes: 256
// Solution to https://atcoder.jp/contests/dp/tasks/dp_v
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int N, MOD;
vector<vector<int>> adj;

// down[node] = number of ways to paint node's subtree where node must be painted black.
// up[node] = number of ways to color the subtree of node that its parent is responsible for, empty coloring included.
vector<int> down, up;

void solve_down(int node, int parent) {
    vector<int> &children = adj[node];

    // Erase the edge from node to parent.
    auto parent_it = find(children.begin(), children.end(), parent);

    if (parent_it != children.end())
        children.erase(parent_it);

    down[node] = 1;

    for (int child : children) {
        assert(child != parent);
        solve_down(child, node);
        down[node] = (long long) down[node] * (down[child] + 1) % MOD;
    }
}

void solve_up(int node, int parent) {
    vector<int> &children = adj[node];
    int n = children.size();
    vector<int> prefix(n + 1, 1), suffix(n + 1, 1);

    for (int i = 0; i < n; i++)
        prefix[i + 1] = (long long) prefix[i] * (down[children[i]] + 1) % MOD;

    for (int i = n - 1; i >= 0; i--)
        suffix[i] = (long long) suffix[i + 1] * (down[children[i]] + 1) % MOD;

    for (int i = 0; i < n; i++)
        up[children[i]] = (1 + (long long) prefix[i] * suffix[i + 1] % MOD * up[node]) % MOD;

    for (int child : children) {
        assert(child != parent);
        solve_up(child, node);
    }
}

int main() {
    scanf("%d %d", &N, &MOD);
    adj.assign(N, {});

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    down.resize(N);
    solve_down(0, -1);

    up.resize(N);
    up[0] = 1;
    solve_up(0, -1);

    for (int i = 0; i < N; i++)
        printf("%lld\n", (long long) up[i] * down[i] % MOD);
}


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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

            int eastToWestStreetCount = Integer.parseInt(inputString[0]);
            int northToSouthStreetCount = Integer.parseInt(inputString[1]);

            int blockCount = (eastToWestStreetCount - 1) * (northToSouthStreetCount - 1);

            System.out.println(blockCount);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
s = input()
a = 0
b = 0
for i in range(len(s)):
    if s[i] == "A":
        a = i
        break
for i in range(len(s)):
    if s[len(s)-1-i] == "Z":
        b = len(s)-1-i
        break
print(b-a+1)

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n >> m;
    vl a(n);
    vl b(n);
    vl c(m);
    vl d(m);

    NREP() {
        cin >> a[i];
        cin >> b[i];
    }

    MREP() {
        cin >> c[j];
        cin >> d[j];
    }

    NREP() {
        ll min_dist = LONG_LONG_MAX;
        ll min_num = -1;
        MREP() {
            ll dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist < min_dist) {
                min_dist = dist;
                min_num = j;
            }
        }
        MSG(min_num + 1)
    }
}


Measured memory_bytes: 256
S = input()


found = False
pprev, prev = S[0],S[1]
t = {pprev, prev}
if len(S) == 2 and len(t) == 1:
    print(1,2)
    found = True
for i in range(2,len(S)):
    t.add(S[i])
    if len(t) == 2:
        print(i - 1, i + 1)
        found = True
    else:
        t.remove(pprev)
    pprev = prev
    prev = S[i]
    t = {pprev, prev}
    if found:
        break
    
if not found:
    print(-1, -1)

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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int p = 0;
  if (n <= k) {
    p += x * n;
    cout << p << '\n';
  } else {
    p += k * x;
    p += (n - k) * y;
    cout << p << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    int a,b;
    cin>>a>>b;
    cout << a * b;
    return 0;
}


Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(10**9)

h,w = map(int, input().split())
board = [[int(j=="#") for j in input()] for i in range(h)]
dxdy = [[0,1], [0,-1], [1,0], [-1,0]]

def dfs(i, j, k, prev):
    if used[i][j] or board[i][j] == prev:
        return
    used[i][j] = 1
    k[board[i][j]] += 1
    for dx, dy in dxdy:
        nx, ny = i+dx, j+dy
        if 0 <= nx < h and 0 <= ny < w and not used[nx][ny] and board[nx][ny] != board[i][j]:
            dfs(nx,ny,k,board[i][j])

used = [[0]*w for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if used[i][j]:
            continue
        k = [0]*2
        dfs(i,j,k, -1)
        ans += k[0]*k[1]
print(ans)

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

using namespace std;
using ll = long long;

int main() {
    int l,r;
    cin>>l>>r;
    int d;
    cin>>d;
    int ans=0;
    for (int i = l; i <= r; ++i) {
        if(i%d==0)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)

typedef long long ll;
const int INF = 1e9;

vector<ll> h;
ll N,A,B;

bool check(ll X){
    auto h2 = h;
    //まとめて爆風を処理
    rep(i,N){
        h2[i] = max(0LL, h[i]-X*B);
    }
    //個々にA-Bずつ減らしていく
    ll cnt = 0;
    rep(i,N){
        cnt += h2[i]/(A-B);
        if(h2[i]%(A-B)!=0){
            cnt++;
        }
    }
    return cnt<=X;
}

int main() {
    cin>>N>>A>>B;
    h.resize(N);
    rep(i,N)cin>>h[i];
    ll ng = 0, ok = INF;
    while(ok - ng > 1){
        ll mid = (ok+ng)/2;
        if(check(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    cout<<ok<<endl;
}

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

int main() {
	int N, a[100010]; cin >> N;
	for(int i=0; i<N; ++i) cin >> a[i];
	sort(a, a+N);
	if(a[N-1]-a[0]>1) cout << "No" << endl;
	else{
	    bool flag;
	    if(a[N-1]==a[0]) flag= (2*a[0]<=N) || (a[0]+1==N);
	    else{
	        int P=1;
	        for(int i=1; a[i-1]==a[i]; ++i) ++P;
	        flag= (P<=a[0]) && ((a[0]-P+1)*2<=N-P);
	    }
	    cout << (flag ? "Yes" : "No") << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    cout << (x - y)*(x - y - 1) / 2 - y << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
int main()
{
  int n,m; cin >> n >> m;
  vi a(m),b(m);
  vii c(m);
  rep(i,m) {
    cin >> a[i] >> b[i];
    c[i].resize(b[i]);
    rep(j,b[i]) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }

  int inf = 1e+9;
  vi dp((1 << n), inf);
  dp[0] = 0;
  rep(i,m) {
    vi ndp((1 << n), inf);
    int S = 0;
    rep(j,b[i]) {
      S += (1 << c[i][j]);
    }
    rep(mask, (1 << n)) {
      chmin(ndp[mask | S], dp[mask] + a[i]);
      chmin(ndp[mask], dp[mask]);
    }
    dp = ndp;
  }

  cout << (dp[(1<<n) - 1] == inf ? -1 : dp[(1<<n) - 1]) << "\n";
  
  return 0;
}


Measured memory_bytes: 3716
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] P = new int[m];
        int[] Y = new int[m];

        for(int i = 0; i < m; i++) {
            P[i] = sc.nextInt();
            Y[i] = sc.nextInt();
            --P[i];
        }
        List<List<Integer>> vals = new ArrayList<>(n);
        for(int i = 0; i < n; i++) {
            vals.add(new ArrayList());
        }
        for(int i = 0; i < m; i++) {
            vals.get(P[i]).add(Y[i]);
        }

        for(int v = 0; v < n; v++) {
            Collections.sort(vals.get(v));
        }

        for(int i = 0; i < m; i++) {
            int v = P[i];
            System.out.print(String.format("%06d", v + 1));


            int id = Collections.binarySearch(vals.get(v), Y[i]);
            System.out.print(String.format("%06d\n", id + 1));
        }
    }
}


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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  VI a(3);
  REP(i,3) {
    cin >> a.at(i);
  }
  SORT(a);
  
  cout << a.at(0)+a.at(1) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


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






























int main(){
    string s;
    cin >> s;
    string a;
    ll ans = 0;
    REP(i, 3){
        a += "R";
        if(s.find(a) != string::npos){
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int H[256],h;
main(){
	scanf("%d",&h);
	for (int i=1;i<=h;i++)scanf("%d",&H[i]); 
	for (int i=1;i<=h;i++){
		printf("node %d: ",i);
		printf("key = %d, ",H[i]);
		if (i/2!=0) printf("parent key = %d, ",H[i/2]);
		if (i*2<=h) printf("left key = %d, ",H[i*2]);
		if (i*2+1<=h) printf("right key = %d, ",H[i*2+1]);
		printf("\n");
	}
}


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n;
    cin >> n;
    int t[200];
    int sum = 0;
    for(int i = 1; i <= n; i++) cin >> t[i], sum += t[i];
    int m;
    cin >> m;
    for(int i = 0; i < m; i++){
        int p, x;
        cin >> p >> x;
        cout << sum - (t[p] - x) << endl;
    }
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		int n=Integer.parseInt(scan.next());
    		
    		if (n<1000) {
    			System.out.print("ABC");
    		}else {
    			System.out.print("ABD");
    		}
    	


    		
     
    }
    }
// end 

Measured memory_bytes: 21844
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

A, B =  map(int, sys.stdin.readline().split())

if B == 1:
    print(0)
    exit()


now = A
cnt = 1
while True:
    if now >= B:
        break
    now += (A - 1)
    cnt += 1

print(cnt)

Measured memory_bytes: 65004
def run():
  N, M = map(int, input().split())
  H = list(map(int, input().split()))
  G = [1] * N
  counter = 0
  for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1]>H[B-1]:
      G[B-1] = 0
    elif H[A-1]<H[B-1]:
      G[A-1] = 0
    else:
      G[A-1] = G[B-1] = 0
  
  for i in range(N):
    if G[i]==1:
      counter+=1
  print(counter)

if __name__ == "__main__":
  run()

Measured memory_bytes: 20004
#include <stdio.h>

int n;
int d[100100], t;

int main()
{
  scanf("%d", &n);
  
  for(int i=1; i<=n; i++)
    scanf("%d", &d[i]);
  
  for(int i=1; i<=n; i++)
    if(d[d[i]]==i)
      t++;
  
  printf("%d\n", t/2);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
//面積は長方形の半分
//複数個の判定は、中心点が（ｘ、ｙ）かの判定

int main(){
    double W,H; cin >> W >> H ;
    LL x,y; cin >> x >> y ;
    double R = W*H/2.000000;
    cout << fixed << setprecision(10) << R << ' ' ;
    int res = 0;
    LL tmp1,tmp2;
        tmp1 = W;
        tmp2 = H;
    if(tmp1 % 2 == 0 && tmp2 % 2 == 0){

        tmp1 = tmp1 / 2 ;
        tmp2 = tmp2 / 2 ;
        if(x == tmp1 && y == tmp2){
            res = 1;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int n, m, a[100], s, i;
 
    s = 0;
    scanf("%d%d",&n,&m);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
        s = s + a[i];
    }
    
    int x, min;
    min = s / (4*m);  
    x = 0;
 
    if(s%(4*m) == 0){
        for(i=0; i<n; i++){
            if(a[i] >= min)
                x++;
        }
    }   
    else{
        for(i=0; i<n; i++){
            if(a[i] > min)
                x++;
        }
    }
    if(x >= m)
        printf("Yes\n");
    else
        printf("No\n");
 
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int ans[10009] = {};
  for (int x=1;x<=100;x++){
    for (int y=1;y<=100;y++){
      for (int z=1;z<=100;z++){
        int n = x*x + y*y + z*z + x*y + y*z + z*x;
        if (n<=10000) ans[n]++;
      }
    }
  }
  for (int i=1;i<=N;i++) cout << ans[i] << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<tuple<string,int,int>> res(N);
  
  for(int i; i<N; i++){
    string s;
    int p;
    cin >> s >> p;
    res.at(i)=make_tuple(s,100-p,i+1);
  }
  sort(res.begin(),res.end());
  
  for(int i; i<N; i++){
    int num;
    tie(ignore,ignore,num) = res.at(i);
    cout << num << endl;
  }
  
}

Measured memory_bytes: 256