akhauriyash/Code-Regression huggingface dataset:
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

typedef struct node_st {
	int key;
	struct node_st *left, *right;
} node_t;

node_t *root;

node_t *node_new(int x) {
	node_t *new = malloc(sizeof(node_t));
	if (new == NULL) exit(1);
	new->key = x;
	new->left = new->right = NULL;
	return new;
}

node_t *insert(node_t *nd, int x) {
	if (!nd) return node_new(x);
	if (x < nd->key) nd->left = insert(nd->left, x);
	else if (nd->key < x) nd->right = insert(nd->right, x);
	return nd;
}

node_t *find(node_t *nd, int x) {
	if (!nd) return NULL;
	if (x < nd->key) return find(nd->left, x);
	else if (nd->key < x) return find(nd->right, x);
	return nd;
}

node_t *delete(node_t *nd, int x) {
	if (!nd) return NULL;
	if (x < nd->key) {
		nd->left = delete(nd->left, x);
		return nd;
	} else if (nd->key < x) {
		nd->right = delete(nd->right, x);
		return nd;
	}

	node_t *res;
	if (nd->left && nd->right) {
		node_t *n = nd->right;
		if (!n->left) {
			res = n;
			res->left = nd->left;
		} else {
			while (n->left->left) n = n->left;
			res = n->left;
			n->left = res->right;
			res->left = nd->left;
			res->right = nd->right;
		}
	} else if (nd->left) {
		res = nd->left;
	} else if (nd->right) {
		res = nd->right;
	} else {
		res = NULL;
	}
	free(nd);
	return res;
}

enum {
	PREORDER,
	INORDER,
};

void print_tree(node_t *nd, int order) {
	if (!nd) return;
	if (order == PREORDER) printf(" %d", nd->key);
	print_tree(nd->left, order);
	if (order == INORDER) printf(" %d", nd->key);
	print_tree(nd->right, order);
}

int main(int argc, char **argv)
{
	int i, n, x;
	char cmd[128];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", cmd);
		if (!strcmp("insert", cmd)) {
			scanf("%d", &x);
			root = insert(root, x);
		} else if (!strcmp("find", cmd)) {
			scanf("%d", &x);
			printf("%s\n", find(root, x) ? "yes" : "no");
		} else if (!strcmp("delete", cmd)) {
			scanf("%d", &x);
			root = delete(root, x);
		} else if (!strcmp("print", cmd)) {
			print_tree(root, INORDER);
			puts("");
			print_tree(root, PREORDER);
			puts("");
		}
	}

	return 0;
}

Measured memory_bytes: 13112
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=1010,M=5010,INF=0x7f7f7f7f;
int pval[N];
namespace T{
	const int E=N<<1;
	int to[E],bro[E],head[N],e=0;
	int f[N],g[N][M];
	inline void init(){
		memset(head,-1,sizeof(head));
		memset(f,127,sizeof(f));
		memset(g,0,sizeof(g));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	inline void add(int u,int v){
		ae(u,v),ae(v,u);
	}
	bool dfs(int x,int fa){
		int *G=g[x],base=0;
		for(int i=head[x],v;~i;i=bro[i]){
			if((v=to[i])!=fa){
				if(!dfs(v,x))return false;
				int a=pval[v],b=f[v];
				if(a>b){
					swap(a,b);
				}
				base+=a;
				if(base>pval[x])return false;
				for(int j=pval[x]-base;j>=0;j--){
					int tmp=G[j];
					if(tmp<INF){
						G[j]+=b;
						apmin(G[j+b-a],tmp+a);
					}
				}
			}
		}
		for(int i=pval[x]-base;i>=0;i--){
			apmin(f[x],G[i]);
		}
		return true;
	}
}
inline bool Main(){
	int n=ni;
	T::init();
	for(int i=2;i<=n;T::ae(ni,i),i++);
	for(int i=1;i<=n;i++){
		pval[i]=ni;
	}
	return T::dfs(1,0);
}
int main(){
	puts(Main()?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}

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

#define MAX_N 200001

int main(void){

    int N,K,p[MAX_N],i,j;
    double CumlativeSum[MAX_N+1],val,ans = 0,ExpectValue[MAX_N];

    scanf("%d %d",&N,&K);
    for(i = 0;i < N;i++){
        scanf("%d",&p[i]);
    }

   CumlativeSum[0] = 0;
    for(i = 1;i <= N;i++){
        ExpectValue[i] = ((double)(p[i-1]+1))/2;
        CumlativeSum[i] = CumlativeSum[i-1] + ExpectValue[i];
        //printf("元の値:%d 期待値:%lf 累積和:%lf\n",p[i-1],ExpectValue[i],CumlativeSum[i]);
    }
    for(i = 0;i <= N-K;i++){
        val = CumlativeSum[i+K]-CumlativeSum[i];
        if(ans < val) ans = val;
        //printf("val:%lf ans:%lf\n",val,ans);
    }

    printf("%lf\n",ans);
    return 0;
}


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

void dfs(int a, int b, int c, long long x) {
    if(x > N) return;
    if(a && b && c == 1) ans++;

    dfs(1, b, c, x * 10 + 3);
    dfs(a, 1, c, x * 10 + 5);
    dfs(a, b, 1, x * 10 + 7);
}

int main() {
    cin >> N;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
  char S[3];
  cin >> S;
  ll i,a,ans;
  a = 0;
  for(i=0;i<=2;i++)
    if(S[i] == 'S') a++;
  if(a == 3) ans = 0;
  if(a == 2) ans = 1;
  if(a == 1 && S[1] == 'S') ans = 1;
  if(a == 1 && S[1] == 'R') ans = 2;
  if(a == 0) ans = 3;
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H,vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> a[i][j]; 
    }
    for(int i = 0; i < W+2; i++) cout << '#';
    cout << endl;
    for(int i = 0; i < H; i++){
        for(int j = -1; j < W+1; j++){
            if(j == -1 || j == W){
                cout << '#';
                if(j == W) cout << endl;
               
            }
            else cout << a[i][j];
        }
    }
    for(int i = 0; i < W+2; i++) cout << '#';
    cout << endl;
}


Measured memory_bytes: 256
def conv(s):
    if s.find('.') == -1:
        s += '.'
    s = s.rstrip('0')
    t = len(s) - s.find('.') - 1
    a = int(s.replace('.', ''))
    if a == 0:
        return (0, 0)
    x, y = -t, -t
    while a % 5 == 0:
        x += 1
        a //= 5
    while a % 2 == 0:
        y += 1
        a //= 2
    return (x, y)


N, *A = open(0).read().split()
N = int(N)

d = {}
for a in A:
    t = conv(a)
    d.setdefault(t, 0)
    d[t] += 1

result = 0
xs = list(d.keys())
for i in range(len(xs)):
    x, y = xs[i]
    t = d[xs[i]]
    if x >= 0 and y >= 0:
        result += t * (t - 1) // 2
    for j in range(i + 1, len(xs)):
        m, n = xs[j]
        if x + m >= 0 and y + n >= 0:
            result += t * d[xs[j]]
print(result)


Measured memory_bytes: 25480
// Lets go to the next level
// AIM EXP at CF *__* asap
// Hit A,B,C faster and reach Expert
// Remember you were also a novice when you started,
// hence never be rude to anyone who wants to learn something!Be calm and help everyone.
// Never open the rank list until and unless you are done with solving problems!
/*HACK ME IF YOU CAN!
░░███▒▒░░░░░░░░░░░░░░░░████
░░████▒░░░░░░░░░░░░░░░███▒█
░░██████░░░░░░░░░░░░░███▒▒▒█
░░██▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒█████▒██
░▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▓▓▓▓▓▓▒▒▒░██
▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒█
▒▒▓▓███████▓░▓▓███████▓▒▒▒▒▒▒
▒▒▓▓▓█▓▄▓█▓░░░▓▓█▓▄▓█▓▓▒▒▒▒▒▒
▒▒▓▓▓▓███▓░░░░░▓▓███▓▓▓▒▒▒▒▒▒
▒▒▒▓▓▓▓▓▓████▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒
▒▒▒▒▓▓▓▓▓▒██▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
░▒▒▒▒▒▒▒▒█████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
░░▒▒▒▒▒▒█▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒
░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
*/

//Author: kaiyu
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};

bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 2e5+ 10;

#define int long long
int32_t main() {
//#ifndef ONLINE_JUDGE
    //freopen("inp1.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
//#endif
    fio
    ll n;
    cin >> n;
    vi a(n);
    ll xr = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        xr ^= a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cout << (xr ^ a[i]) << " ";
    }



    cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 4780
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k,r,s,p;
  string str;
  cin>>n>>k>>r>>s>>p;
  cin>>str;
  vector<string> v(k);
  rep(i,n){
    v[i%k]+=str[i];
  }
  ll ans=0;
  rep(i,v.size()){
    bool flag=true;
    rep(j,v[i].size()){
      
        if(flag){
          if(v[i][j]=='r'){
              ans+=p;
          }else if(v[i][j]=='s'){
              ans+=r;
          }else if(v[i][j]=='p'){
              ans+=s;
          }
          if(j+1<v[i].size()){
            if(v[i][j]==v[i][j+1]){
              flag=false;
            }
          }
        }else{
          flag=true;
        }
        
        
      

    }
  }
  cout<<ans<<endl;
  
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;
    cout << N/3 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=1e3+5;






int main()
{

        
         int n;
         cin >> n;
         double dp[n+1]={0};
         dp[0]=1.0;
         for(int i=0;i<n;i++)
         {
             double prob;
             cin >> prob;
           //  cout <<prob<<endl;
             for(int j=i+1;j>=0;j--)
             {
                 dp[j]=( j==0 ? 0 : dp[j-1]*prob) + dp[j]*(1- prob);
             }
         }
         double ans=0;
         rep(i,0,n+1)
         {
             int tail=n-i;
             if(tail<i)
              ans+=dp[i];
         }
        cout<<fixed <<setprecision(10)<<ans;

     return 0;
}



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

int main() {
    int N, Y;
    cin >> N >> Y;
    tuple<int, int, int> answer = make_tuple(-1, -1, -1);
    for (int a = 0; a < N+1; a++) {
        if (Y < a * 10000) break;
        for (int b = 0; b < N - a + 1; b++) {
            if (Y < a * 10000 + b * 5000) break;
            int c = N - a - b;
            if (Y == a * 10000 + b * 5000 + c * 1000) answer = make_tuple(a, b, c);
        }
    }

    cout << get<0>(answer) << " " << get<1>(answer) << " " << get<2>(answer) << endl;
}

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

int main() {
  int n;
  scanf("%d", &n);
  int w, sum[n+1], ans = INT_MAX;
  sum[0] = 0;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &w);
    sum[i+1] = sum[i] + w;
  }
  for (size_t i = 0; i < n+1; i++) {
    int tmp = abs(sum[n] - (2*sum[i]));
    ans = (tmp < ans) ? tmp : ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int Child_Num = scan.nextInt();
		int Candy_Num = scan.nextInt();
	
		int[] Wanted_Candy = new int[Child_Num] ;
				
		for (int i = 0; i<Child_Num; i++){
			Wanted_Candy[i] =  scan.nextInt();
		}
		
		Arrays.sort(Wanted_Candy);
		
		int Candy_Sum = 0;
		int j =0;
		while(j < Child_Num ){
			if ( Candy_Sum + Wanted_Candy[j] > Candy_Num){
				break;
			}
			else{
				Candy_Sum = Candy_Sum + Wanted_Candy[j] ;	
				j++;
			}
		}
		
		if((j == Child_Num) && Candy_Sum != Candy_Num){
			j=j-1;
		}
	
		System.out.println(j);
	
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a,b[100010],n;
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>a;
while(a%2==0){
a/=2;
b[i]++;
}
}
int s1=0,s2=0;
for(int i=0;i<n;i++)
{
if(b[i]==1)
s1++;
if(b[i]>=2)
s2++;
}
if((n-s1/2*2)/2<=s2)
cout<<"Yes";
else
cout<<"No";
system("pause");
return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	double A = a,B = b;
	double C = (A*B)/2;
	printf("%.6f ",C);
	int a1,b1;
	a1 = a+1;
	b1 = b+1;
	if(a1%2 == 0||b1%2 == 0)
	{
		cout<<"0\n";return 0;
	}
	if(c == (a1-1)/2&&d == (b1-1)/2)
	{
		cout<<"1\n";return 0;
	}
	cout<<"0\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)
ll dp[102][100002];
ll knapsack(ll weight[],ll val[],ll n,ll w){
	
    if(n==0 || w==0) return 0;
    if(dp[n][w]!=-1) return dp[n][w];
    if(weight[n-1]<=w) return dp[n][w]=max(val[n-1]+
        knapsack(weight,val,n-1,w-weight[n-1]),knapsack(weight,val,n-1,w));
        return dp[n][w]=knapsack(weight,val,n-1,w);
}
int main(){
    ll n,w;
    cin>>n>>w;
    ll weight[n],val[n];
    for(ll i=0;i<n;i++) cin>>weight[i]>>val[i];
	memset(dp,-1,sizeof(dp));
    cout<<knapsack(weight,val,n,w);
	return 0;
}


Measured memory_bytes: 83328
#include<stdio.h>

int gcd(int x,int y){
  int r;
  if(x>y){
    int temp;
    temp=x;
    x=y;
    y=temp;
  }
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int main(){
  int a,b,x;
  scanf("%d %d",&a,&b);
  x=gcd(a,b);
  printf("%d\n",x);
  return 0;
}



Measured memory_bytes: 2120
from collections import defaultdict
n = int(input())
s = input()
ans = ""
cnt1=cnt2=cnt3=0
tmp = ""
for i in s:
    if i==")":

        if cnt2==0:
            cnt1+=1
            tmp+="("
            ans+=")"
        if cnt2>0:
            cnt2-=1
            ans+=")"

    if i=="(":
        cnt1=0
        cnt2+=1
        ans+="("
        if len(tmp)>0:
            ans = tmp+ans
            tmp=""

if cnt1>0:
    ans = "("*cnt1+ans
if cnt2>0:
    ans += ")"*cnt2
print(ans)


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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
//ll a[SZ];
//ll b[SZ];



int main() {
    FR;
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin1(s);

    for0(i, s.size()) {
        x = s[i] - '0';
        c = (c*10 + x);
        c %= 9;
    }

    (c == 0) ? cout << "Yes\n" : cout << "No\n";

    return 0;
}



Measured memory_bytes: 3716
N, M, X = gets.split(' ').map(&:to_i)
arr = gets.split(' ').map(&:to_i)

a1 = 0
a2 = 0

for i in (0..N)
  if arr.include?(i)
    if i < X
      a1 += 1
    else
      a2 += 1
    end
  end
end

puts [a1, a2].min

Measured memory_bytes: 1788
#include<stdio.h>
int main() {

	int n, i;
	int c[] = { 0,0,0,0 };
	char s[100000][4];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", s[i]);

		if (s[i][0] == 'A' && s[i][1] == 'C')
			c[0]++;
		else if (s[i][0] == 'W' && s[i][1] == 'A')
			c[1]++;
		else if (s[i][0] == 'T' && s[i][1] == 'L' && s[i][2] == 'E')
			c[2]++;
		else if (s[i][0] == 'R' && s[i][1] == 'E')
			c[3]++;
	}

	printf("AC x %d\n", c[0]);
	printf("WA x %d\n", c[1]);
	printf("TLE x %d\n", c[2]);
	printf("RE x %d\n", c[3]);

	return 0;
}

Measured memory_bytes: 2524
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  string str[n];
  for(int i=0;i<n;i++)
    cin>>str[i];
  int vx[8]={0,1,1,1,0,-1,-1,-1};
  int vy[8]={1,1,0,-1,-1,-1,0,1};
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(str[i][j]=='#')
	cout<<'#';
      else{
	int cnt=0;
	for(int k=0;k<8;k++){
	  if(i+vx[k]>=0&&i+vx[k]<n&&j+vy[k]>=0&&j+vy[k]<m)
	    if(str[i+vx[k]][j+vy[k]]=='#')
	      cnt++;
	}
	  cout<<cnt;
      }
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

int main(){
	ll zer = 0;
	ll n, l, r, ans, x, y, z; cin >> n;
	vector<vector<ll>> prol(n,vector<ll>(2));
	ll maxl = 0;
	ll minr = 1000000000;
	ll maxdis = 0;
	REP(i,n) {
		cin >> l >> r;
		prol[i][0] = l;
		prol[i][1] = r;
		maxl = max(l,maxl);
		minr = min(r,minr);
	}
	REP(i,n) if (prol[i][0]!=l && prol[i][1]!=r){
		maxdis=max(maxdis,prol[i][1]-prol[i][0]+1);
	}
	ans=max(minr-maxl+1,zer)+maxdis;
	vector<vector<ll>> prol2(n,vector<ll>(3));
	REP(i,n){
		prol2[i][2]=max(zer,minr-prol[i][0]+1);
		prol2[i][1]=max(zer,prol[i][1]-maxl+1);
		prol2[i][0]=(prol2[i][1]+1)*10000000000-prol2[i][2];
	}
	sort(prol2.begin(),prol2.end());
	vector<vector<ll>> ansl(n,vector<ll>(2));
	ansl[0][1]=prol2[0][2];
	ansl[n-1][0]=prol2[n-1][1];
	FOR(i,1,n-1) ansl[i][1]=min(ansl[i-1][1],prol2[i][2]);
	FORD(i,n-2,0) ansl[i][0]=min(ansl[i+1][0],prol2[i][1]);

	//REP(i,n) cout << ansl[i][0] << " " << ansl[i][1] << endl;

	FOR(i,0,n-2) ans = max(ans,ansl[i][1]+ansl[i+1][0]);
	cout << ans << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<int>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a)   memset(a,0,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main() {
    zoom;
    ll n;
    in1(n);
    string in;
    ll a1=0,a2=0,a3=0,a4=0;
    forn(i,n){
        in1(in);
        if (in=="AC") a1++;
        else if (in=="WA") a2++;
        else if (in=="TLE") a3++;
        else a4++;
    }
    cout<<"AC x "<<a1<<endl;
    cout<<"WA x "<<a2<<endl;
    cout<<"TLE x "<<a3<<endl;
    cout<<"RE x "<<a4<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

const int N = 100005, M = N * 2;

int n, u, v;
vi g[N];
int du[N], dv[N];

void dfs(int p, int pre, int dis, int du[N]) {
    du[p] = dis;
    repit (it, g[p]) {
        if (*it == pre) continue;
        dfs(*it, p, dis + 1, du);
    }
}

int gao() {
    dfs(u, -1, 0, du);
    dfs(v, -1, 0, dv);
    int ans = 0, res = n;
    FOR (i, 1, n) {
        if (du[i] == dv[i]) res = min(res, du[i]);
        if (du[i] < dv[i]) ans = max(ans, dv[i] - 1);
    }
    if (res != n) ans = max(ans, res);
    return ans;
}

int main() {
    int x, y;
    while (~in3(n, u, v)) {
        FOR (i, 1, n) g[i].clear();
        rep (i, n - 1) {
            in2(x, y);
            g[x].pb(y);
            g[y].pb(x);
        }
        printf("%d\n", gao());
    }
    return 0;
}


Measured memory_bytes: 11648
#include <stdio.h>

int selectionSort(int *,int);

int main(){
  int N,j;
  int A[100];
  int sw =0;

  scanf("%d",&N);

  for(j=0; j < N;j++){
    scanf("%d",&A[j]);
  }

  sw = selectionSort(A,N);

  for(j=0 ;j < N;j++){

    if(j > 0)printf(" ");

    printf("%d",A[j]);
  }


  printf("\n%d\n",sw);

  return 0;
}


int selectionSort(int A[],int N){
  int i,j,minj,temp;
  int sw = 0;

  for(i=0 ;i < N -1;i++){
    minj = i;

    for(j=i ;j < N;j++){

      if( A[j] < A[minj] )minj = j;
      
      }

	temp = A[i];
	A[i] = A[minj];
	A[minj] = temp;

	if( i != minj )sw++;
  
  }

  return sw;
}

	



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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();

        list.add(0, S);

        sc.close();

        int ans = 1;
        int i = 1;
        while (true) {
            int tmp = list.get(i - 1);

            if (tmp % 2 == 0) {
                if (list.contains(tmp / 2) && i > 1) {
                    ans = i;
                    break;
                }
                list.add(i, tmp / 2);
            } else {
                if (list.contains(3 * tmp + 1) && i > 1) {
                    ans = i;
                    break;
                }
                list.add(i, 3 * tmp + 1);
            }
            i++;
        }

        System.out.println(ans + 1);
    }
}

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

typedef long long ll;
typedef pair<int,int>P;
#define INF (1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>

/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);*/
/*--------------------------------------------*/


int main(){
    int n,k;cin>>n>>k;
    int a[n];
    REP(i,n)cin>>a[i];
    vector<int> b(n+1);
    REP(i,n)b[a[i]]++;
    sort(RALL(b));
    //REP(i,n+1)cout<<b[i]<<endl;
  	int ans=0;
    FOR(i,k,n+1)ans+=b[i];
  	cout<<ans<<endl;
}



/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/


Measured memory_bytes: 1792
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    ll anum,bnum;
    anum=0; bnum=0;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){
            bnum+=a[i]-b[i];
        }else{
            anum+=(b[i]-a[i])/2;
            anum+=(b[i]-a[i])%2;
            bnum+=(b[i]-a[i])%2;
        }
        //cout<<anum<<" "<<bnum<<endl;
    }
    if(anum>=bnum){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 384
from collections import defaultdict
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]

cnt = defaultdict(int)
cnt[(0, 0)] = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        cnt[(points[i][0] - points[j][0], points[i][1] - points[j][1])] += 1

# print(cnt)
ans = n - max(cnt.values())
print(ans)


Measured memory_bytes: 9588
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#define ll long long
#define oku7 1000000007
using namespace std;
vector<int> v[2000001];

int main(){
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	for (int i = 1; i <= N; i++){
		sort(v[i].begin(), v[i].end());
	}
	bool ans = false;
	for (size_t i = 0; i < v[1].size(); i++){
		if (binary_search(v[v[1][i]].begin(), v[v[1][i]].end(), N)) ans = true;
	}
	if (ans) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";




	

	return 0;
}

Measured memory_bytes: 50688
//11:52-15:25
#include <stdio.h>
#include <stdlib.h>

 //   #define DEBUG
int icache[300*300+1];
int jcache[300*300+1];

long costcache[300*300+1];


int abs(int a){if (a < 0) return -a; else return a;}
int main(){
    int H,W,D;
    scanf("%d %d %d",&H,&W,&D);
    
    int n;
    int i = 0, j = 0;
    for(int k = 0; k < H*W; k++){
        scanf("%d",&n);
        icache[n] = i;
        jcache[n] = j;
        
        ++j;
        if(j >= W){
            ++i;
            j = 0;
        }
    }

    #ifdef DEBUG
      for(int k = 0 ; k <= H*W ; k++){
          printf("k=%d,i=%d,j=%d\n",k,icache[k],jcache[k]);
      }
    
    #endif
    
    
    int Q;
    scanf("%d",&Q);
    
    for(int k = 0; k <= H*W; k++){
        costcache[k] = -1;
    }
    
    for(int k = 0; k < Q; k++){
        int L, R;
        scanf("%d %d", &L,&R);
        
        int ind = L;
        if(costcache[L] < 0 || costcache[R] < 0){
            int cost = 0;
            
            while(ind <= H*W){
                ind = ind + D;
            }
            
            ind = ind-D;
            costcache[ind] = 0;
            int costcacheold = 0;
            while(ind != L){
                int prev_i = icache[ind];
                int prev_j = jcache[ind];
                ind = ind - D;
                int current_i = icache[ind];
                int current_j = jcache[ind];
                
                costcache[ind] = costcacheold + abs(prev_i-current_i)+abs(prev_j-current_j);
                costcacheold = costcache[ind];
                current_i = prev_i;
                current_j = prev_j;
                #ifdef DEBUG
                    printf("L=%d,current(i,j)=(%d,%d),prev(i,j)=(%d,%d)\n",
                            L,current_i,current_j,prev_i,prev_j);
                #endif
            }
        }
        printf("%ld\n",costcache[L]-costcache[R]);
    }
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
ll A[100000];
ll B[100000];
int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    ll mask = 0;
    ll ans = 0;
    for (int i = 29; i >= 0; i--) {
        if ((K & (1 << i)) == 0) {
            mask |= (1 << i);
            continue;
        }
        ll sum = 0;
        for (int j = 0; j < N; j++) {
            if (A[j] & mask) continue;
            if (A[j] & (1 << i)) continue;
            sum += B[j];
        }
        ans = max(ans, sum);
    }
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] & mask) continue;
        sum += B[i];
    }
    ans = max(ans, sum);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

// const int kMaxN;

int a, b, c, d;
string ans;

signed main() {
  cin >> a >> b >> c >> d;

  if (ABS(a-c) <= d || (ABS(a-b) <= d && ABS(b-c) <= d)) {
    ans = "Yes";
  } else {
    ans = "No";
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
result = 0
for i in range(1,N+1,2):
  #print(i)
  A = 0
  for j in range(1,i+1):
    #print(j)
    if i % j == 0:
      A += 1
  if A == 8:
    result += 1
print(result)

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

int main() {
  string s; cin >> s;
  char prev = s[0];
  int ans = s.size();
  for (int i=1; i<s.size(); i++) {
    char curr = s[i];
    if (prev==curr) {
      i++;
      ans--;
      prev = '0';
    } else {
      prev = curr;
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace AtCoder.Abc
{
    class A_171_αlphabet
    {
        // https://atcoder.jp/contests/abc171/tasks/abc171_a
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();
            // 大文字
            if (Regex.IsMatch(s,"[A-Z]"))
            {
                string result = "A";
                Console.WriteLine(result);
            }
            else if (Regex.IsMatch(s,"[a-z]"))
            {
                string result = "a";
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26736
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5)
#define INFL LLONG_MAX
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;



int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;

	// Write your code here

	int t = 1;
	//cin >> t;
	while (t--) {
		ll n, m, sum;
		cin >> n >> m >> sum;
		vl a(n), b(m);
		vl prefix_a(n + 1);
		prefix_a[0] = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			prefix_a[i + 1] = a[i] + prefix_a[i];
		}
		//disp(0, n + 1, prefix_a);
		for (int i = 0; i < m; i++) {
			cin >> b[i];
		}

		ll l = 0;
		ll r = n;
		ll mid;
		ll ans = 0;
		ll mx = -1;
		while ( l <= r) {
			mid = l + (r - l) / 2;
			if (prefix_a[mid] <= sum) {
				ans = mid;
				l = mid + 1;
			} else {
				r = mid - 1;
			}
		}

		mx = max(ans, mx);
		ll cnt = mx;

		ll total = prefix_a[ans];
		int j = 0;
		while (j < m) {
			if (total + b[j] <= sum) {
				total += b[j];
				j++;
				cnt++;
			} else {
				if (ans == 0) break;
				ans--;
				total -= a[ans];
				cnt--;
			}
			mx = max(cnt, mx);
		}

		cout << mx << "\n";
	}


	return 0;
}

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

int main(void){
	int N;
	cin >> N;
	int n;
	bool ok = true;
	for(int i = 0; i < N; ++i){
		cin >> n;
		if(n % 2 == 0){
			if(n % 3 != 0 && n % 5 != 0){
				ok = false;
			}
		}
	}
	if(ok){
		cout << "APPROVED" << endl;
	}else{
		cout << "DENIED" << endl;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int x,y,z,k;cin >> x >> y >> z >> k;
    vector<LL> a(x),b(y),c(z);
    for (int i = 0; i < x; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < y; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < z; i++) {
        cin >> c[i];
    }
    vector<LL> s;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            s.pb(-(a[i]+b[j]));
        }
    }
    sort(ALL(s));
    LL l=0,r=30000000001;
    while(abs(r-l)>1){
        LL mid = (r+l)/2;
        bool flag=false;
        int sum = 0;
        for (int i = 0; i < z; i++) {
            sum += lower_bound(ALL(s),-(mid-c[i]))-s.begin();
        }
        if(sum>=k) l = mid;
        else r = mid;
    }
    vector<LL> ans;
    for (int i = z-1; i >= 0; i--) {
        for (int j = 0; j < s.size(); j++) {
            if(-s[j]+c[i]<r) break;
            ans.pb(-s[j]+c[i]);
        }
    }
    sort(RALL(ans));
    for (int i = 0; i < k; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 141664
#include <iostream>
#include <vector>
#include <string>
#define MAXN 3005
using namespace std;

string s, t;
int dp[MAXN][MAXN];
vector<char> res;

void reconstruct(int i, int j) {
    if (i == 0 || j == 0) {
        res.clear();
    }
    else if (s[i] == t[j]) {
        reconstruct(i-1, j-1);
        res.push_back(s[i]);
    }
    else if (dp[i][j] == dp[i-1][j]) {
        reconstruct(i-1, j);
    }
    else {
        reconstruct(i, j-1);
    }
}


int main() {
	string u, v;
	cin >> u >> v;
	s = " " + u;
	t = " " + v;

	for (int i=0; i<s.length(); i++) {
		for (int j=0; j<t.length(); j++) {
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			if (s[i] == t[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	reconstruct(s.length() - 1, t.length() - 1);
	if (res.size() == 0) {
		cout << " ";
	}
	else {
		for (char c : res) {
			cout << c;
		}
	}
}

Measured memory_bytes: 35584
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int result;
		for(result = 1; result <= N; result *= 2) {
			if(result * 2 > N ) {
				break;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 27064
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define endl '\n'
#define int ll
#define gcd __gcd
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)

void solve(){
    
    int n;
    cin >> n;
    int i = 0;
    int val = 0;
    while(true){
        i++;
        val = val*10 + 7;
        int rem = val % n;
        if (rem==0) break;
        if (i > n) {
            i = -1 ;
            break;
        }
        val = rem;
    }
    cout << i << endl;
}


int32_t main(){

    #ifndef ONLINE_JUDGE 
  
    freopen("input.txt", "r", stdin); 
  
    freopen("output.txt", "w", stdout); 
  
    #endif 

    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 

    int t = 1;
    // cin >> t;
    while(t--){
        solve();
        // cout << "Case #" << (tt+1) <<":" << endl;
    }
}

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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( true ) {
	    int n = stdin.nextInt();
	    if ( n == 0 ) {
		break;
	    }

	    int count = 0;
	    while ( n != 1 ) {
		if ( n % 2 == 0 ) {
		    n /= 2;
		} else {
		    n = n * 3 + 1;
		}
		count++;
	    }
	    System.out.println( count );
	}	
    }    
}

Measured memory_bytes: 15360
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=anslist.end()?" ":"\n");itr--;}
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int dp[310][310];

int main(){
    int n;
    while(cin >> n && n){
        vector<int> line(n);
        REP(i,0,n) cin >> line[i];
        REP(i,0,310){
            REP(j,0,310){
                dp[i][j]=0;
            }
        }

        REP(len,2,n+1){
            REP(left,0,n){
                int right = left + len;
                if(right > n)continue;
                if(dp[left+1][right-1]==len-2 && abs(line[left]-line[right-1])<=1){
                    dp[left][right]=len;
                }

                REP(mid,left+1,right){
                    dp[left][right]=max(dp[left][right],dp[left][mid]+dp[mid][right]);
                }
            }
        }
        cout << dp[0][n] << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
int main(void)
{
    int X;
    cin >> X;
    int max = 120;

    vector<vector<ll>> xmap(2*max+1, vector<ll>(2*max+1));

    for(int i = -max; i <= max; i++){
        for(int j = -max; j <= max; j++){
            xmap[max+i][max+j] = pow(i, 5) - pow(j, 5);
        }
    }

    int resA = 0, resB = 0;

    for(int i = -max; i <= max; i++){
        for(int j = -max; j <= max; j++){
            if(X == xmap[max+i][max+j]){
                resA = i;
                resB = j;
                break;
            }
        }
    }

    cout << resA << " " << resB << endl;

    return 0;
}


Measured memory_bytes: 4516
import java.util.*;
import java.util.stream.*;

class Main {
	Scanner sc;
	int N, M;
	PriorityQueue<Integer> prices;

	Main() {
		sc = new Scanner(System.in);
		prices = new PriorityQueue<>(Comparator.reverseOrder());
	}
	
	void calc() {
		N = sc.nextInt();
		M = sc.nextInt();
		
		for (int i = 0; i < N; i++) prices.add(sc.nextInt());
		for (int i = 0; i < M; i++) {
			Iterator<Integer> it = prices.iterator();
			int p = it.next();
			it.remove();
			prices.add(p>>>1);
		}
		System.out.println(prices.stream().
			collect(Collectors.summingLong(p -> (long)p) ));
	}

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

Measured memory_bytes: 60488