akhauriyash/Code-Regression huggingface dataset:
n,a,b,c,d = map(int, input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1


if c<d:
    for i in range(b,d):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    for i in range(a,c):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

flag = False
for i in range(b-1,d):
    if s[i]==s[i+1]==s[i+2]==".":
        flag = True
        break
if not flag:
    print("No")
    exit()

for i in range(b,d):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
for i in range(a,c):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
print("Yes")

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int long long, int long long>> L(N);
  int A, B;
  for (int i = 0; i < N; i++) {
    cin >> A >> B;
    L.at(i) = make_pair(A, B);
  }
  
  sort(L.begin(), L.end());
  
  int long long ans = 0;
  int drinks = 0;
  for (int i = 0; i < N; i++) {
    if (drinks + L.at(i).second < M) {
      ans += L.at(i).first * L.at(i).second;
      drinks += L.at(i).second;
    } else {
      ans += L.at(i).first * (M - drinks);
      drinks = M;
      break;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    ll l,r;
    cin>>l>>r;
    if(r-l>=2300){
        cout<<0<<endl;
    }else{
        ll ans=INF;
        FOR(i,l,r+1){
            FOR(j,i+1,r+1){
                chmin(ans,1ll*i*j%2019);
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
def check(T):
    res = 0
    for h in H:
        tmp = (h - B * T + A - B - 1) // (A - B)
        if tmp <= 0:
            break
        res += tmp
    return True if res <= T else False

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort(reverse=True)
res = 0
left = 0
right = 10 ** 9
while right != left:
    mid = (left + right) // 2
    if check(mid):
        right = mid
    else:
        left = mid + 1
print(left)


Measured memory_bytes: 13236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100005;
ll x,y,a,b,c,p[maxn],q[maxn],r[maxn];
vector<ll>v;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>x>>y>>a>>b>>c;
	for(int i=1; i<=a; i++) cin>>p[i];
	for(int i=1; i<=b; i++) cin>>q[i];
	for(int i=1; i<=c; i++) cin>>r[i];
	sort(p+1,p+a+1,greater<int>());
	sort(q+1,q+b+1,greater<int>());
	sort(r+1,r+c+1,greater<int>());
	for(int i=1; i<=x; i++)	v.push_back(p[i]);
	for(int i=1; i<=y; i++) v.push_back(q[i]);
	sort(v.begin(),v.end());
	int pos=1;
	for(int i=0; i<v.size(); i++) {
		if(r[pos]<=v[i]) break;
		v[i]=r[pos];
		pos++;
		if(pos>c) break;
	}
	ll ans=0;
	for(int i=0; i<v.size(); i++) {
		ans+=v[i];
	}
	cout<<ans;
	return 0;
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	map<string,int> D;
	rep(i,n){
		string s; cin>>s;
		++D[s];
	}

	int mx=0;
	for(auto p:D) mx=max(mx,p.second);

	for(auto p:D) if(p.second==mx) cout<<p.first<<'\n';

	return 0;
}


Measured memory_bytes: 25216
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.Char
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as UV

main :: IO()
main = do
  [n, k] <- getIntList
  [as, bs] <- transpose . (sortOn head) <$> replicateM n getIntList
  let cs = tail . scanl (+) 0 $ bs
  print . fst . head . dropWhile ((< k) . snd) $ zip as cs


readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = BS.readInt . BS.dropWhile isSpace

getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine



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

void swap(int *,int *);

int main(){
	int n,a[100],c=0,flag;
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	
	flag=1;
	while(flag){
		flag=0;
		for(int j=n-1;j>0;j--){
			if(a[j]<a[j-1]){
				swap(&a[j],&a[j-1]);
				c++;
				flag=1;
			}
		}
	}



	for(int i=0;i<n;i++){
		cout << a[i];
		if(i!=n-1) cout << " ";
	}
	cout << endl;
	cout << c << endl;
	return 0;
}

void swap(int *a,int *b){
	int w;
	w= *a;
	*a=*b;
	*b=w;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;

int main(){
  cin >> n;
  ll ans = 1;
  rrep(i, n){
    ans = ans * i;
    ans = ans % DIV;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
using namespace std;

int main(){
  int n,y;
  cin >> n >> y;
  int a=-1,b=-1,c=-1;
  for (int i =0;i<=n;i++){
    for (int j =0;j<=n-i;j++){
      int ot=y-10000*i-5000*j;
      if (ot == 1000*(n-i-j)){
	a=i;
	b=j;
	c=n-i-j;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int Q=1<<19;
int fa[Q];
int gf(int x)
{return fa[x]==x?x:(fa[x]=gf(fa[x]));}
int X[Q],Y[Q],Z[Q];
int MOD;
int id(int x,int y,int z)
{return (x-1)*6+y*2+z;}
void Merge(int x,int y)
{
    x=gf(x),y=gf(y);
    fa[x]=y;
}
int had[2][1<<21];
void Deal(int x,int y,int z)
{
    for(int q=0;q<3;q++)
        for(int p=0;p<2;p++)
            Merge(id(x,q,p),id(y,((q<<1)+z)%3,p^1));
}
int main()
{
    int n,m,q,gg=-1;
    scanf("%d%d%d%d",&n,&m,&q,&MOD);
    for(int i=1;i<=(n+1)*6;i++)
        fa[i]=i;
    for(int i=1;i<=m;i++){
        scanf("%d%d%d",&X[i],&Y[i],&Z[i]);
        if(i>1){
            int v=abs(Z[i]-Z[1]);
            gg=gg<0?v:__gcd(gg,v);
        }
    }
    if(!gg)gg=MOD;
    MOD=__gcd(MOD,3*gg);
    int zz=Z[1]%gg;
    for(int i=1;i<=m;i++){
        int x=X[i],y=Y[i],z=(Z[i]-zz)/gg%3;
        Deal(x,y,z),Deal(y,x,z);
    }
    for(int i=0,j=zz%MOD;i<(MOD<<1);i++,j=(j<<1)%MOD)
        had[i&1][j]=1;
    while(q--){
        int s,t,r,als=0;
        scanf("%d%d%d",&s,&t,&r);
        for(int q=0;q<3;q++)
            for(int p=0;p<2;p++)
                if(gf(id(t,0,0))==gf(id(s,q,p))&&had[p][(r+zz+(3-q)*gg)%MOD]){
                    als=1;
                    break;
                }
        puts(als?"YES":"NO");
    }
    return 0;
}

Measured memory_bytes: 16768
A, B, C = map(int, input().split())
dict = {}
ans = 0
while ans < 1000000:
    tpl = tuple(sorted([A, B, C]))
    if tpl in dict:
        ans = -1
        break
    elif A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break
    dict[tpl] = True
    A, B, C = (B + C) // 2, (C + A) // 2, (A + B) // 2
    ans += 1
print(ans)

Measured memory_bytes: 38384
[r, c] = [int(x) for x in raw_input().split()]

A = []

counter = 0
while counter < r:
    raw = [int(x) for x in raw_input().split()]
    A.append(raw + [sum(raw)])
    counter += 1

A.append([sum([A[raw][col] for raw in range(r)]) for col in range(c + 1)])
for data in A:
    print(" ".join([str(x) for x in data]))

Measured memory_bytes: 6480
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, M = map(int, input().split())
    H = list(map(int,input().split()))
    R = [1] * N
    for i in range(M):
        a , b= map(int,input().split())
        a-=1
        b-=1
        if H[a]>H[b]:
            R[b]=0
        elif H[b]>H[a]:
            R[a]=0
        else:
            R[b]=0
            R[a]=0
    print(sum(R))

if __name__ == '__main__':
    main()

Measured memory_bytes: 20028
def main():
    D, T, S = map(int, input().split())
    cnt = 0
    if D % S == 0:
        cnt = D // S
    else:
        cnt = D // S
        cnt += 1

    if cnt <= T:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()

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

#define INF 100000000000.0
using namespace std;

int main(void){

	double high,min=INF,max=-1*INF;

	while(scanf("%lf",&high)!=EOF){
		if(max<high) max=high;
		if(min>high) min=high;
	}

	printf("%.1f\n",max-min);


	return 0;
}

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

int compare(const void *a, const void *b){
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A > *B) return -1;
	if (*A < *B) return 1;
	return 0;
}
int main(){
	int N,K,ans=0;
	scanf("%d%d",&N,&K);
	int l[N];
	for(int i=0;i<N;i++)scanf("%d",&l[i]);
	qsort(l,N,sizeof(int),compare);
	for(int i=0;i<K;i++)ans+=l[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
int main(){
	int sum=0;
	while(true){
		char c=getchar();
		if(c==' '||c=='\r'||c=='\n'||c=='\0'||c==EOF)break;
		sum+=c-'0';
		sum%=9;
	}
	if(sum)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    ll ans=1;
    bool tate=true;
    rep(i,n){
        if(i==0){
            if(s1[i]==s2[i]){
                tate=true;
                ans*=3;
            }
            else{
                tate=false;
                ans*=6;
                i++;
            }
        }
        else{
            if(s1[i]==s2[i]){
                if(tate) ans=(ans*2)%MOD;
                tate=true;
            }
            else{
                if(tate) ans=(ans*2)%MOD;
                else ans=(ans*3)%MOD;
                tate=false;
                i++;
            }
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 256
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 200005;

/*******************************************************************/




int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t, z = 1; cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < k; i++) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    n: usize,
    av: [isize; n]
  };

  let mut add_table: HashMap<isize, u64> = HashMap::new();
  for (i, &a) in av.iter().enumerate() {
    let i = (i + 1) as isize;
    *add_table.entry(i + a).or_insert(0) += 1;
  }
  let mut sub_table = HashMap::new();
  for (i, &a) in av.iter().enumerate() {
    let i = (i + 1) as isize;
    *sub_table.entry(i - a).or_insert(0) += 1;
  }
  let mut res = 0_u64;
  for (&a, &c) in &add_table {
    res += c * sub_table.get(&a).unwrap_or(&0);
  }
  println!("{}", res);
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
// c++ cpp.cpp -o cpp.exe -std=c++14
// ./cpp.exe

int main() {
	int n, q;
	cin >> n >> q;

	queue<string> que_nm;
	queue<int> que_tm;
	int time = 0;

	for (int i = 0; i < n; i++) {
		string nm; cin >> nm;
		int tm;	cin >> tm;
		que_nm.push(nm);
		que_tm.push(tm);
	}

	while (que_nm.size() != 0) {
		string nm;
		int tm;

		nm = que_nm.front();
		que_nm.pop();

		tm = que_tm.front();
		que_tm.pop();

		if (tm > q) {
			time += q;
			que_nm.push(nm);
			que_tm.push(tm - q);
		}
		else {
			time += tm;
			cout << nm << " " << time << endl;
		}
	}
	return 0;
}



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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	ll n , k ;
	cin >> n >> k ;
	ll sum = 0 ;
	ll power = 1 ;
	ll count = 0;
	while ( sum < n ){
		sum += (power * (k-1));
		power *= k ;
		count ++ ;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    vector<int> a(n+1,0);
    rep(i,0,n) cin>>a[i+1];

    vector<int> box(n+1,0);
    int cnt=0;
    for(int i=n; i>=1; i--){
        int temp_sum=0;
        for(int j=1; i*j<=n; j++){
            temp_sum+=box[i*j];
        }
        if(temp_sum%2!=a[i]){
            box[i]=1;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    rep(i,1,n+1){
        if(box[i]==1) cout<<i<<" "<<endl;
    }
}

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

int main()
{
    int n, k, s, g, dist, ret = INT_MAX;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
        cin >> x.at(i);

    for (int i = 0; i < n - k + 1; i++)
    {
        s = x.at(i);
        g = x.at(i + k - 1);
        if (g < 0)
            dist = abs(s);
        else if (s < 0)
            dist = g - s + min(abs(s), g);
        else
            dist = g;
        ret = min(ret, dist);
    }
    cout << ret << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int a[10000];
int main()
{
	a[1] = 2;
	a[2] = 3;
	int k = 2;
	for (int i = 4;i < 55555;i++)
	{
		int j;
		for (j = 1;j <= sqrt(k)+1;j++)
		{
			if (i%a[j] == 0)
				break;
		}
		if (j > sqrt(k) + 1)
		{
			k++;
			a[k] = i;
		}
	}

	int n;
	cin >> n;
	for (int i = 1;i < 10000;i++)
	{
		if (a[i] % 10 == 1)
		{
			printf("%d ", a[i]);
			n--;
		}
		if (n == 0)
		{
			printf("\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

//-----end of template-----//

int main(){
    int a, b;
    cin >> a >> b;
    cout << 2 * b - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const ll N = 1e6, inf = 1e9;

ll br[N], dp[N];
vector< pair< ll , ll > > ar;
map<ll, ll>mp;

int bs(int l, int m, int val)
{
    ll ans = m;
    ll lo = l + 1, hi = m;
    while(lo <= hi)
    {
        ll m = (lo + hi)/2;
        if(ar[m].first >= val)
        {
            ans = m;
            hi = m-1;
        }
        else lo = m+1;
    }
    return ans;
}
int foo(int pos, int n)
{
    if(pos == n) return 0;
    ll &ret = dp[pos];
    if( ret != -1 ) return dp[pos];
    ll id = bs(pos, n, ar[pos].second);
    ret = max(foo(pos+1, n), 1 + foo(id, n));
    return ret;
}
int main()
{
    ll n, x, y;
    cin>>n;
    memset(dp, -1, sizeof dp);
    for(int i = 0; i < n; i++)
    {
        cin>>x>>y;
        ar.pb({x - y, x + y});
    }
    sort(ar.begin(), ar.end());
    cout<<foo(0, n)<<"\n";
    return 0;
}


Measured memory_bytes: 14832
#include <stdio.h>
#include <string.h>
int main(void){
  char s[100000];
  scanf("%s",s);
  if(s[0]=='A') puts("T");
  else if(s[0]=='T')puts("A");
  else if(s[0]=='G')puts("C");
  else if(s[0]=='C')puts("G");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *print;
  int key;
};
typedef struct node * Node;

Node root;
void insert(int);
void inorder(Node );
void preorder(Node );

int main(){
  int s, t, i;
  char c[10];

  scanf("%d", &s);

  for ( i=0 ; i<s ; i++ ){
    scanf("%s", c);
    if ( c[0]=='i' ){
      scanf("%d", &t);
      insert(t);
    } 
    if ( c[0]=='p' ){
      inorder( root );
      printf("\n");
      preorder( root );
      printf("\n");
    } 
  }
  return 0;
}

void insert( int k ){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc( sizeof( struct node ) );
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while( x!=NIL ){
    y = x;
    if( z->key<x->key ) x = x->left;
    else x = x->right;
  }

  z->print = y;
  if( y==NIL ) root = z;
  else if( z->key<y->key ) y->left = z;
  else y->right = z;
}

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

Measured memory_bytes: 24040
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N,M = map(int,input().split())

xy = [list(map(int,input().split())) for _ in range (M)]

# DAG TopoSort
in_count = [0]*N
edge = [[] for _ in range(N)]
for u,v in xy:
    in_count[v-1] += 1
    edge[u-1].append(v-1)

S = []
L = [] #Sort結果
index = [0]*N # 頂点vのLにおけるインデックスindex[v]
for i in range(N):
    if in_count[i]==0: S.append(i)
while S:
    v = S.pop()
    index[v] = len(L)
    L.append(v)
    for nv in edge[v]:
        in_count[nv] -= 1
        if in_count[nv]==0:
            S.append(nv)

dp = [0] * N
for i,v in enumerate(L):
    for nv in edge[v]:
        dp[index[nv]] = max(dp[index[nv]], dp[i]+1)

print(max(dp))


Measured memory_bytes: 76764
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
ll a,b,c;
cin >> a >> b >> c;
c = c-a-b;
if(c>0&&4*a*b<c*c) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  std::vector<int> a(2 * n + 1);
  for(int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  std::vector<int> v;
  for(int i = 1; i <= n; ++i) {
    bool ok = 0;
    for(int j = n; j > 0; --j) {
      if(a[j] == j) {
        // cout << *(a.begin() + j) << endl;
        a.erase(a.begin() + j);
        v.eb(j);
        ok = 1;
        break;
      }
    }
    if(!ok) {
      cout << -1 << endl;
      return 0;
    }
  }
  reverse(all(v));
  for(auto i : v) {
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int h,w;
  cin>>h>>w;
  char a[20][20];
  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
      cin>>a[j][i];
  int b[20][20][4][16];
  memset(b,0,sizeof(b));
  queue<pair<pair<int,int>,pair<int,int> > > c;
  c.push(make_pair(make_pair(0,0),make_pair(0,0)));
  while(c.empty()==0){
    int x,y,d,m;
    x=c.front().first.first;
    y=c.front().first.second;
    d=c.front().second.first;
    m=c.front().second.second;
    if(a[x][y]=='@')
      break;
    c.pop();
    if(b[x][y][d][m]==0){
      b[x][y][d][m]=1;
      switch(a[x][y]){
      case '<':
	c.push(make_pair(make_pair(x?x-1:w-1,y),make_pair(2,m)));
	break;
      case '>':
	c.push(make_pair(make_pair(x+1==w?0:x+1,y),make_pair(0,m)));
	break;
      case '^':
	c.push(make_pair(make_pair(x,y?y-1:h-1),make_pair(3,m)));
	break;
      case 'v':
	c.push(make_pair(make_pair(x,y+1==h?0:y+1),make_pair(1,m)));
	break;
      case '_':
	if(m){
	  c.push(make_pair(make_pair(x?x-1:w-1,y),make_pair(2,m)));
	}else{
	  c.push(make_pair(make_pair(x+1==w?0:x+1,y),make_pair(0,m)));
	}
	break;
      case '|':
	if(m){
	  c.push(make_pair(make_pair(x,y?y-1:h-1),make_pair(3,m)));
	}else{
	  c.push(make_pair(make_pair(x,y+1==h?0:y+1),make_pair(1,m)));
	}
	break;
      case '?':
	c.push(make_pair(make_pair(x?x-1:w-1,y),make_pair(2,m)));
	c.push(make_pair(make_pair(x+1==w?0:x+1,y),make_pair(0,m)));
	c.push(make_pair(make_pair(x,y?y-1:h-1),make_pair(3,m)));
	c.push(make_pair(make_pair(x,y+1==h?0:y+1),make_pair(1,m)));
	break;
      case '+':
      case '-':
	if(a[x][y]=='+')
	  m=(m+1)%16;
	else
	  m=m?m-1:15;
      case '.':
	if(0){
	}else if(d==0){
	  c.push(make_pair(make_pair(x+1==w?0:x+1,y),make_pair(0,m)));
	}else if(d==1){
	  c.push(make_pair(make_pair(x,y+1==h?0:y+1),make_pair(1,m)));
	}else if(d==2){
	  c.push(make_pair(make_pair(x?x-1:w-1,y),make_pair(2,m)));
	}else if(d==3){
	  c.push(make_pair(make_pair(x,y?y-1:h-1),make_pair(3,m)));
	}
	break;
      default:
	m=a[x][y]-'0';
	if(0){
	}else if(d==0){
	  c.push(make_pair(make_pair(x+1==w?0:x+1,y),make_pair(0,m)));
	}else if(d==1){
	  c.push(make_pair(make_pair(x,y+1==h?0:y+1),make_pair(1,m)));
	}else if(d==2){
	  c.push(make_pair(make_pair(x?x-1:w-1,y),make_pair(2,m)));
	}else if(d==3){
	  c.push(make_pair(make_pair(x,y?y-1:h-1),make_pair(3,m)));
	}
	break;
      }
    }
  }
  cout<<(c.empty()?"NO":"YES")<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll X, Y, Z, K; cin >> X >> Y >> Z >> K;
  vector<ll> A(X);
  vector<ll> B(Y);
  vector<ll> C(Z);
  REPLL(i, X) cin >> A[i];
  REPLL(i, Y) cin >> B[i];
  REPLL(i, Z) cin >> C[i];
  vector<ll> AB;
  REPLL(i, X){
    REPLL(j, Y){
      AB.push_back(A[i]+B[j]);
    }
  }
  sort(AB.begin(), AB.end(), greater<ll>());
  sort(C.begin(), C.end(), greater<ll>());
  priority_queue<ll> pq;
  ll idx1 = min(X*Y, K), idx2 = min(Z, K);
  REPLL(i, idx1){
    REPLL(j, idx2){
      pq.push(AB[i]+C[j]);
    }
  }
  ll cnt = 0;
  while(cnt < K){
    cout << pq.top() << endl;
    pq.pop();
    cnt++;
  }
}

Measured memory_bytes: 43368
S = list(str(input()))
T = list(str(input()))
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
count = 0

for i in range(len(S)):
    if S[i] != T[i]:
        count += 1

print(count)


Measured memory_bytes: 12560
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto s = sread();
    auto t = sread();
    // writeln(s);
    long ans = long.max;
    foreach (i; 0 .. ((s.length - t.length) + 1))
    {
        // writeln(s[i .. (i + (t.length))]);
        ans = min(ans, func(s[i .. (i + (t.length))], t));

    }
    writeln(ans);
}

long func(string s, string t)
{
    long cnt;
    foreach (i; 0 .. s.length)
    {
        if (s[i] != t[i])
        {
            cnt += 1;
        }
    }
    return cnt;
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3640
from collections import defaultdict
N = int(input())
counter = defaultdict(int)

for _ in range(N):
  s = input()
  alpha = [0] * 26
  a = ord("a")
  for c in s:
    alpha[ord(c)-a] += 1 
  counter[tuple(alpha)] += 1

res = 0
for k,v in counter.items():
  res +=v*(v-1)//2

print(res)


Measured memory_bytes: 126168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	int n;
	std::vector<int> a;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	a.resize(n);
	for(int i = 0; i < n; i++){
		a[i] = i + 1;
	}

	do{
		std::cout << a[0];
		for(int i = 1; i < n; i++){
			std::cout << " " << a[i];
		}
		std::cout << std::endl;
	} while(std::next_permutation(a.begin(), a.end()));

	return 0;
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int min_i, max_i;
  cin >> min_i >> max_i;
  REPS(i,min_i, max_i+1) {
    if(i % n == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG";
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3632
S=input()
N=len(S)
mod= 998244353

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

R=0
B=0

RB=[[0,0]]*N

for i in range(N):
    s=S[i]
    if s=="0":
        R+=2
    elif s=="1":
        R+=1
        B+=1
    else:
        B+=2
    RB[i]=[R,B]

DP=[0]*(R+1)
DP[0]=1

for i in range(N):
    NDP=[0]*(R+1)
    red,blue=RB[i]
    for r in range(R+1):
        if DP[r]==0:
            continue
        if r+1<=red:
            NDP[r+1]+=DP[r]
        if i-r+1<=blue:
            NDP[r]+=DP[r]
    DP=NDP


ANS=0
for r in range(R+1):
    red=R-r
    blue=B-(N-r)

    ANS=ANS+DP[r]*Combi(red+blue,blue)
    ANS%=mod
print(ANS)

Measured memory_bytes: 100772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int MAX = 3e5;

vector<int> G[MAX];
vector<int> d(MAX, -1);

void bfs(int s) {
  d[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v: G[u]) {
      if (d[v] != -1) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
}


int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].push_back(v + n);
    G[u + n].push_back(v + 2 * n);
    G[u + 2 * n].push_back(v);
  }
  int s, t;
  cin >> s >> t;
  s--, t--;

  bfs(s);
  cout << (d[t] == -1 ? -1 : d[t] / 3) << endl;



  



  
  return 0;
}

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

int main() {
  int L,R,d;
  cin >> L >> R >> d;
  int count=0;

  for(int i=L; i<R+1; i++){
    if(i%d==0){
      count++;
    }
  }


  cout << count << endl;

}


Measured memory_bytes: 3632
#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 M = 1000002;

int main() {
  ll n;
  cin >> n;
  // vector<ll> a(n);
  vector<int> array(M);
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) {
    if(array[a[i]] != 0){
      array[a[i]] = 2;
      continue;
    }
    for(int j = a[i]; j < M; j += a[i]) array[j]++;
  }
  int ans = 0;
  for(int ar : a) {
    if(array[ar] == 1) ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7936
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	int n;
	cin >> n;
	Vi L(n);
	rep(i, n) cin >> L[i];

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (L[i] < L[j] + L[k] && L[j] < L[i] + L[k] && L[k] < L[i] + L[j]) {
					if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
						ans++;
					}
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int t[110], v[110];
int l[110], r[110];

double f(int idx, double x) {
  if (x < l[idx]) return v[idx] + (l[idx] - x);
  if (x > r[idx]) return v[idx] + (x - r[idx]);
  return v[idx];
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    l[i] = sum;
    sum += t[i];
    r[i] = sum;
  }
  v[N] = v[N + 1] = 0;
  l[N] = r[N] = 0;
  l[N + 1] = r[N + 1] = sum;
  double ans = 0;
  for (int i = 0; i < sum * 2; i++) {
    double x = i / 2.0;
    double a = 110, b = 110;
    for (int j = 0; j < N + 2; j++) {
      a = min(a, f(j, x));
      b = min(b, f(j, x + 0.5));
    }
    ans += (a + b) * 0.25;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll x,a,b;
cin>>x>>a>>b;
if(abs(a-x)>abs(b-x)){
    cout<<"B"<<endl;
}else{
    cout<<"A"<<endl;
}
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngll(chrono::steady_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int L;
	cin >> L;
	int n, m = 0;
	vector<vector<pair<int, int>>> adj;
	function<void(int)> solve = [&](int x){
		if(x <= 1){
			adj.emplace_back();
			return;
		}
		solve(x / 2);
		int c = int(adj.size());
		adj.emplace_back();
		adj[c - 1].emplace_back(c, 0);
		adj[c - 1].emplace_back(c, x / 2);
		m += 2;
		if(x & 1){
			adj[0].emplace_back(c, x - 1);
			++ m;
		}
	};
	solve(L);
	n = int(adj.size());
	cout << n << " " << m << "\n";
	for(int u = 0; u < n; ++ u){
		for(int i = 0; i < int(adj[u].size()); ++ i){
			int v, w;
			tie(v, w) = adj[u][i];
			cout << u + 1 << " " << v + 1 << " " << w << "\n";
		}
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    int base = 26;
    vi ans;
    while(n){
        int tmp = (n-1)%base;
        ans.push_back('a' + tmp);
        n -= tmp;
        n /= base;
        //n--;
    }
    reverse(all(ans));
    string s(all(ans));
    cout << s << "\n";

    return 0;
}

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

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << endl;
}

int main() {
  string s;
  cin >> s;
  ll n = s.size() + 1;
  // ll ans = 0;
  vector<ll> a(n, 0);
  rep(i, s.size()) {
    if ((s[i] == '<') && !(a[i] < a[i + 1]))
      a[i + 1] = a[i] + 1;
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if ((s[i] == '>') && !(a[i] > a[i + 1]))
      a[i] = a[i + 1] + 1;
  }
	ll ans=0;
	rep(i,s.size()+1) ans+=a[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ld dist( pll a, pll b )
{
    ll dx = (a.F - b.F)*(a.F - b.F);
    ll dy = (a.S - b.S)*(a.S - b.S);
    ld ans = sqrt(dx+dy);
    return ans;
}

int main() 
{
    fastio();

    int n;
    cin>>n;
    vector<pll>v(n);
    vector<int>ind(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].F>>v[i].S;
        ind[i] = i;
    }

    ld ans = 0;
    do
    {
        for(int i=1;i<n;i++)
        {
            ans += dist(v[ind[i]], v[ind[i-1]]);
        }
    }while( next_permutation(all(ind)) );

    for(int i=0;i<n;i++)
        ans /= (i+1);

    cout<<fixed<<setprecision(9)<<ans,nl;

    return 0;
}

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

int main() {
    ll A,B,C,K; 
    cin >> A >> B >> C >> K;;
    if(K%2 == 0) cout << A-B << endl;
    else cout << B-A << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
	input!{
		n: i16
	}

	match n%10 {
		2 | 4 | 5 | 7 | 9 => println!("hon"),
		0 | 1 | 6 | 8 => println!("pon"),
		_ => println!("bon")
	}
}

Measured memory_bytes: 2164
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);++(i))
#define REP1(i,n) for((i)=1;(i)<=(int)(n);++(i))

int main() {
    //clock_t start = clock();
    ios::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b; cin >> a >> b;
    if (a == b) {
        cout << "Draw" << endl;
    } else {
        if (a == 1) cout << "Alice" << endl;
        else if (b == 1) cout << "Bob" << endl;
        else {
            if (a > b) cout << "Alice" << endl;
            else cout << "Bob" << endl;
        }
    }
    //clock_t stop = clock();
    //cout << (double)(stop-start)/CLOCKS_PER_SEC << " (s)" << endl;
    return 0;
}


Measured memory_bytes: 256