stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>

#include <cstdlib>

#include <string>

#include <iostream>

#include <queue>



using namespace std;



const char *X, *Y;

int X_length, Y_length;

bool alreadySeenTable[256];

int table_lcs[1001][1001];



int lcs(int x_begin, int y_begin) {

	int i, j, to;

	int max = 0;

	int v_lcs;

	

	if (table_lcs[x_begin][y_begin] != -1) {

		return table_lcs[x_begin][y_begin];

	}

	

	for (i = 0; i < 256; i++) {

		alreadySeenTable[i] = false;

	}

	i = x_begin;

	j = y_begin;

	to = Y_length-1;

	while(i <= X_length-1) {

		bool found = false;

		while (j <= to) {

			if (X[i] == Y[j]) {

				v_lcs = lcs(i + 1, j + 1) + 1;

				if (v_lcs > max) {

					max = v_lcs;

				}

				found = true;

				break;

			}

			else {

				j++;

			}

		}

		if (found == false) {

			i++;

			j = y_begin;

		}

		else {

			i++;

			to = j - 1;

			j = y_begin;

		}

	}

	return table_lcs[x_begin][y_begin] = max;

}



int main() {



	int N;

	cin >> N;

	string stringX, stringY;



	for (int i = 1; i <= N; i++) {

		for (int i = 0; i < 1001; i++) {

			for (int j = 0; j < 1001; j++) {

				table_lcs[i][j] = -1;

			}

		}

		cin >> stringX >> stringY;

		X = stringX.c_str();

		X_length = stringX.size();

		Y = stringY.c_str();

		Y_length = stringY.size();

		printf("%d\n", lcs(0, 0));

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

using namespace std;



int lengthOfLcs_r(const char x[], const char y[], int ix, int iy, int xsize, int ysize, int **lengthTable) {

	if (ix == xsize || iy == ysize) {

		return 0;

	}

	if (lengthTable[ix][iy] != -1) {

		return lengthTable[ix][iy];

	}

	if (x[ix] == y[iy]) {

		return lengthTable[ix][iy] = lengthOfLcs_r(x, y, ix + 1, iy + 1, xsize, ysize, lengthTable) + 1;

	}

	return lengthTable[ix][iy] = max(lengthOfLcs_r(x, y, ix, iy + 1, xsize, ysize, lengthTable), lengthOfLcs_r(x, y, ix + 1, iy, xsize, ysize, lengthTable));

}



int lengthOfLcs(string x, string y) {

	int xsize = x.size(), ysize = y.size();



	int **lengthTable = new int*[xsize];

	for (int i = 0; i < xsize; ++i) {

		lengthTable[i] = new int[ysize];

		fill_n(lengthTable[i], ysize, -1);

	}



	int ret = lengthOfLcs_r(x.c_str(), y.c_str(), 0, 0, xsize, ysize, lengthTable);

	

	for (int i = 0; i < xsize; i++) {

		delete[] lengthTable[i];

	}

	delete[] lengthTable;

	

	return ret;

}



int main() {

	int q;

	string x, y;



	cin >> q;

	for (int i = 0; i < q; ++i) {

		cin >> x >> y;

		cout << lengthOfLcs(x, y) << endl;

	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;



#define N 1000



int lcs(string X,string Y){

	int c[N+1][N+1];

	int m = X.size();

	int n = Y.size();

	X = ' ' + X;

	Y = ' ' + Y;

	for(int i=0;i<=m;i++)c[i][0]=0;

	for(int i=1;i<=n;i++)c[0][i]=0;

	for(int i=1;i<=m;i++){

		for(int j=1;j<=n;j++){

			if(X[i]==Y[j]){

				c[i][j] = c[i-1][j-1]+1;

			}else if(c[i][j-1]>=c[i-1][j]){

				c[i][j] = c[i][j-1];

			}else{

				c[i][j] = c[i-1][j];

			}

		}

	}

	return c[m][n];

}



int main(){

	int n;

	string X,Y;

	cin >> n;

	for(int i=0;i<n;i++){

		cin >> X >> Y;

		printf("%d\n",lcs(X,Y));

	}

	return 0;

}




// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cstring>

#include <queue>

#include <vector>

#include <functional>

#include <map>

#include <set>

#include <cmath>

#include <string>

#define SIZE 200005

#define INF 1000000005LL



#include<iostream>



using namespace std;

typedef long long int ll;

typedef pair <int,int> P;



static const int N = 1005;



int n;

ll K;

int dp[N][N];



int main()

{

	scanf("%d",&n);

	string s1,s2;

	for(int k=0;k<n;k++){

		//scanf("%s",&s1);

		//scanf("%s",&s2);

		cin >> s1 >> s2;

		s1 = ' ' + s1;

		s2 = ' ' + s2;

		for(int i=0;i<s1.size();i++)dp[i][0]=0;

		for(int i=0;i<s2.size();i++)dp[0][i]=0;

		for(int i=1;i<s1.size();i++){

			for(int j=1;j<s2.size();j++){

				if(s1[i]==s2[j]){

					dp[i][j] = dp[i-1][j-1]+1;

				}else{

					dp[i][j] = max(dp[i-1][j],dp[i][j-1]);

				}

				//printf("%d\n",dp[i][j]);

			}

		}

		printf("%d\n",dp[s1.size()-1][s2.size()-1]);

	}



	return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

#include <utility>

#include <algorithm>

#include <vector>

#include <cstdio>

#include <cstring>



using namespace std;



string s1,s2;

int l[1010][1010];

bool flag[1010][1010];



int L(int i,int j){

	//cout<<i<<" "<<j<<endl;

	if(i<0||j<0){

		return 0;

	}

	else if(s1.at(i)==s2.at(j)){

		if(!flag[i][j]){

			l[i][j]=1+L(i-1,j-1);

			flag[i][j]=true;

		}

		return l[i][j];

	}

	else{

		if(!flag[i][j]){

			int a=L(i,j-1);

			int b=L(i-1,j);

			l[i][j]=a>b?a:b;

			flag[i][j]=true;

		}

		return l[i][j];

	}

}



int main(){

	int q;

	cin>>q;

	for(int i=0; i<q; i++){

		cin>>s1>>s2;

		for(int j=0; j<1010; j++){

			for(int k=0; k<1010; k++){

				flag[j][k]=false;

			}

		}



		cout<<L(s1.size()-1,s2.size()-1)<<endl;

	}

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) REP(i,0,n)

#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)

#define repr(i, n) REPR(i, n, 0)

#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)

#define pb push_back

#define all(r) r.begin(),r.end()

#define rall(r) r.rbegin(),r.rend()

#define fi first

#define se second



typedef long long ll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;



const ll INF = 1e18;

const ll MOD = 1e9 + 7;

const double EPS = 1e-8;



template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}

template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}



void solve() {

    string s, t;

    cin >> s >> t;

    int n = s.size(), m = t.size();

    vector<vi> dp(n+2, vi(m+2));

    rep(i, n+1) rep(j, m+1) {

        // cout << i << " " << j << endl;

        if(i >= n) {

            chmax(dp[i][j+1], dp[i][j]);

        }

        else if(j >= m) {

            chmax(dp[i+1][j], dp[i][j]);

        }

        else if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);

        else {

            chmax(dp[i+1][j], dp[i][j]);

            chmax(dp[i][j+1], dp[i][j]);

        }

    }

    cout << dp[n][m] << '\n';

    // rep(i, n+2) {

    //     rep(j, m+2) {

    //         cout << " " << dp[i][j];

    //     }

    //     cout << endl;

    // }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    rep(i, n) solve();

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cassert>

#include <algorithm>

#include <iostream>

#include <vector>

#include <string>



class TLcsSolver

{

    typedef std::vector<std::vector<int> > TTable;

    TTable FTable;

    std::string FArray1;

    std::string FArray2;



    int Count(int i, int j)

    {

        if(i == 0 || j == 0) return 0;

        if(FArray1[i-1] == FArray2[j-1]){

            return FTable[i-1][j-1] + 1;

        }

        return std::max(FTable[i-1][j], FTable[i][j-1]);

    }

    void Solve()

    {

        for(std::size_t i = 1; i < FTable.size(); ++i){

            for(std::size_t j = 1; j < FTable[i].size(); ++j){

                FTable[i][j] = Count(i, j);

            }

        }

    }

public:

    TLcsSolver(const std::string& a, const std::string& b)

     : FArray1(a), FArray2(b)

     , FTable(a.size()+1, std::vector<int>(b.size()+1, 0))

    {

        Solve();

        // Print();

    }

    int Answer()const

    {

        return FTable[FArray1.size()][FArray2.size()];

    }

    void Print()const

    {

        for(std::size_t i = 0; i < FTable.size(); ++i){

            for(std::size_t j = 0; j < FTable[i].size(); ++j){

                std::cout << FTable[i][j] << '\t';

            }

            std::cout << '\n';

        }

    } 

};



int main()

{

    int n;

    std::cin >> n;

    for(int i = 0; i < n; ++i){

        std::string a, b;

        std::cin >> a >> b;

        std::cout << TLcsSolver(a, b).Answer() << std::endl;

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>



#define SIZE 1010

class TLcsSolver

{

    int FTable[SIZE][SIZE];

    const char* FArray1;

    const char* FArray2;

    const int Fn1;

    const int Fn2;



    int Count(int i, int j)

    {

        if(i == 0 || j == 0) return 0;

        if(FArray1[i-1] == FArray2[j-1]){

            return FTable[i-1][j-1] + 1;

        }

        return std::max(FTable[i-1][j], FTable[i][j-1]);

    }

    void Solve()

    {

        for(std::size_t i = 1; i < Fn1; ++i){

            for(std::size_t j = 1; j < Fn2; ++j){

                FTable[i][j] = Count(i, j);

            }

        }

    }

    void Print()const

    {

        for(std::size_t i = 0; i < Fn1; ++i){

            for(std::size_t j = 0; j < Fn2; ++j){

                printf("%d\t", FTable[i][j]);

            }

            printf("\n");

        }

    } 

public:

    TLcsSolver(const char* a, const char* b)

     : FArray1(a), FArray2(b)

     , Fn1(std::strlen(a)), Fn2(std::strlen(b))

    {

        Solve();

        // Print();

    }

    int Answer()const

    {

        return FTable[Fn1-1][Fn2-1];

    }

};



int main()

{

    int n;

    std::scanf("%d\n", &n);

    char a[SIZE];

    char b[SIZE];

    for(int i = 0; i < n; ++i){

        std::fgets(a, SIZE, stdin);

        std::fgets(b, SIZE, stdin);

        std::printf("%d\n", TLcsSolver(a, b).Answer());

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long int

#define sz  200010

using namespace std;





string ss[sz];



int main()

{





    string x="";



    ll h,w,i,j,k,p,a,b;



    cin>>h>>w;



    for(i=1; i<=h; i++)cin>>ss[i];



    for(i=1; i<=w+2; i++)x+="#";



    cout<<x<<endl;

    for(i=1; i<=h; i++)

    {

        cout<<"#"<<ss[i]<<"#"<<endl;

    }

    cout<<x<<endl;







    return 0;

}




// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



int N,K,i;

string a;





int main(){

    cin>>N>>K;

    for(i=1;i<=K+2;i++){

        cout<<"#";

    }

    cout<<endl;

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

        cin>>a;

        cout<<"#"<<a<<"#"<<endl;

    }

    for(i=1;i<=K+2;i++){

        cout<<"#";

    }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main(){

  int h,w;

  vector<string> a(100);

  cin>>h>>w;

  for(int i=0; i<h; i++)

    cin>>a.at(i);

  

  for(int i=0; i<w+2; i++)

    cout<<"#";

  cout<<endl;

  

  for(int i=0; i<h; i++)

    cout<<"#"<<a.at(i)<<"#"<<endl;;

  

  for(int i=0; i<w+2; i++)

    cout<<"#";

  cout<<endl;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main(void)

{

  int h,w;

  char a[101][101];

  scanf("%d%d",&h,&w);

  for(int i=0; i<h; i++)

    scanf("%s",a[i]);

  

  for(int i=0; i<w+2; i++)

    printf("#");

  puts("");

  

  for(int i=0; i<h; i++)

    printf("#%s#\n",a[i]);

  

  for(int i=0; i<w+2; i++)

    printf("#");

  puts("");

  

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

bool can(int a,int b,int d){

    return abs(a-b)<=d;

}



int main()

{

    int a,b,c,d;

    while(~scanf("%d%d%d%d",&a,&b,&c,&d)){

        if(can(a,c,d)|| (can(a,b,d) && can(b,c,d))){

            puts("Yes");

        }else{

            puts("No");

        }



    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



#include<stdlib.h>





int main()



{



int a,b,c,d,e,f,g;



scanf("%d%d%d%d",&a,&b,&c,&d);





e=abs(a-c);

f=abs(a-b);

g=abs(b-c);

if((e<=d) || (f<=d && g<=d))



{



printf("Yes\n");



}





else



{



printf("No\n");



}



return 0;



}  

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include <stdio.h>

#include<algorithm>

#include<string.h>

#include<cmath>

#include <vector>

using namespace std;

int main()

{

    int a,b,c,d;

    scanf("%d%d%d%d",&a,&b,&c,&d);

    if(abs(a-c)<=d)printf("Yes");

    else if(abs(a-b)<=d&&abs(b-c)<=d)printf("Yes");

    else printf("No");

}






// Optimized solution to the same problem (faster):
#include<stdio.h>



#include<stdlib.h>





int main()



{



int a,b,c,d,e,f,g;



scanf("%d%d%d%d",&a,&b,&c,&d);





e=abs(a-c);

f=abs(a-b);

g=abs(b-c);

if((e<=d) || (f<=d && g<=d))



{



printf("Yes\n");



}





else



{



printf("No\n");



}



return 0;



}  

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

void display()

{

    int a, b, c, d;

    cin>>a>>b>>c>>d;

    puts(abs(a-c) <= d || abs(a-b) <= d && abs(b-c) <=d ? "Yes": "No");

}

int main(void)

{

    display();

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



#include<stdlib.h>





int main()



{



int a,b,c,d,e,f,g;



scanf("%d%d%d%d",&a,&b,&c,&d);





e=abs(a-c);

f=abs(a-b);

g=abs(b-c);

if((e<=d) || (f<=d && g<=d))



{



printf("Yes\n");



}





else



{



printf("No\n");



}



return 0;



}  

// Fastest known solution for this problem:
// Original C++ solution (slower):
		/**Bismillahir Rahmanir Rahim**/





#include<bits/stdc++.h>

using namespace std;

#define ll long long



#define pb push_back

#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define clr(v) v.clear()

vector<ll>v;

pair<ll,ll>p;

map<ll,ll>mp;

set<ll>st;

deque<ll>dq;

priority_queue<ll>pq;

#define f(i,b) for(i=0;i<b;i++)

#define f1(i,b) for(i=1;i<=b;i++)

#define fr(i,b)for(i=b-1;i>=0;i--)

ll mn=INT_MAX,mx=INT_MIN;

ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag,l,x,k,dif;



string s,str;





ll a[200007],b[200007];

int main()

{





   ll d,a,b,c;



cin>>a>>b>>c>>d;

if(abs(c-a)<=d)

    cout<<"Yes";

else

{

    ll dif=abs(a-b);

    ll dif1=abs(b-c);

    if(dif>d||dif1>d)

        cout<<"No";

    else cout<<"Yes";

}

return 0;

}








// Optimized solution to the same problem (faster):
#include<stdio.h>



#include<stdlib.h>





int main()



{



int a,b,c,d,e,f,g;



scanf("%d%d%d%d",&a,&b,&c,&d);





e=abs(a-c);

f=abs(a-b);

g=abs(b-c);

if((e<=d) || (f<=d && g<=d))



{



printf("Yes\n");



}





else



{



printf("No\n");



}



return 0;



}  

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int a,b,c,d,x,y,z;

    cin>>a>>b>>c>>d;

    if(a>b)

    {

        x=a-b;

    }

    else

    {

        x=b-a;

    }

    if(b>c)

    {

        y=b-c;

    }

    else

    {

        y=c-b;

    }

    if(c>a)

    {

        z=c-a;

    }

    else

    {

        z=a-c;

    }

    if( (x<=d && y<=d)|| z<=d)

    {

        cout<<"Yes"<<endl;

    }

    else

    {

        cout<<"No"<<endl;

    }





    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

int main()

{

    int a,b,c,d;

    scanf("%d%d%d%d",&a,&b,&c,&d);

    if((abs(a-b))<=d&&(abs(b-c))<=d)

        {

            printf("Yes");

        }

    else if((abs(a-c))<=d)

        {

            printf("Yes");

        }

    else

        {

            printf("No");

        }





    return 0;



}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define PI acos(-1)

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

#define full(a, n) a, a + n

#define ma(type, size) (type *)malloc(sizeof(type) * size)

#define F first

#define S second

#define PB push_back

#define MP make_pair

#define MT make_tuple

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

#define f1n(i, n) for (i = 1; i <= (n); i++)

#define fab(i, a, b) for (i = (a); i <= (b); i++)

#define fr(i, b, a) for (i = (b); i >= (a); i--)



using namespace std;



/*

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,

	tree_order_statistics_node_update> indexed_set;

//*/

typedef long long int ll;

typedef long int lo;

typedef vector<int> vi;

typedef pair<int, int> pi;

typedef tuple<int, int, int> ti;



typedef vector<ll> vll;

typedef pair<ll, ll> pll;

typedef tuple<ll, ll, ll> tll;



//* utility function

inline bool compare(ll i, ll j)

{

    return i < j;

}

//*/



//* function prototypes

template< typename T>

T gcd(T a, T b);

//*/



//int row, column;

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

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

ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};

#ifdef DEBUG

#endif // DEBUG



int main()

{

    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);

    //freopen("output.txt", "w", stdout);



    ll number_of_test_case = 1, test_case;

    //cin >> number_of_test_case;

    for (test_case = 1; test_case <= number_of_test_case; test_case++)

    {

        ll a, b, c, d;



        cin >> a >> b >> c >> d;

        if ((abs(a-c) <= d) or ((abs(a-b) <= d) and (abs(b-c) <= d)))

            cout << "Yes\n";

        else cout << "No\n";

    }

    return 0;

}

template< typename T>

T gcd(T a, T b)

{

    if (b == 0)

        return a;

    return gcd(b, a%b);

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>



int main()

{

    double a, b, c, dif, d1, d2, d3, count=0;

    scanf("%lf%lf%lf%lf", &a, &b, &c, &dif);

    

    d1 = abs(a-c);

    d2 = abs(a-b);

    d3 = abs(b-c);

    

    if(d1<=dif)

        count=1;

    if(d2<=dif && d3<=dif)

        count=1;

    

    if(count==0)

        printf("No\n");

    else

        printf("Yes\n");

    

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define  ll long long int

main()

{

  ll a,b,c,d;

  cin>>a>>b>>c>>d;

 if((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d)

    cout<<"Yes"<<endl;

 else cout<<"No"<<endl;



}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>



int main()

{

    double a, b, c, dif, d1, d2, d3, count=0;

    scanf("%lf%lf%lf%lf", &a, &b, &c, &dif);

    

    d1 = abs(a-c);

    d2 = abs(a-b);

    d3 = abs(b-c);

    

    if(d1<=dif)

        count=1;

    if(d2<=dif && d3<=dif)

        count=1;

    

    if(count==0)

        printf("No\n");

    else

        printf("Yes\n");

    

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int a,b,c,d;

    cin>>a>>b>>c>>d;

     if(abs(a-c)<=d)

    {

        cout<<"Yes"<<endl;

    }

    else if(abs(a-b)<=d && abs(b-c)<=d)

    {

         cout<<"Yes"<<endl;

    }

    else

    {

        cout<<"No"<<endl;

    }



}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>



int main()

{

    double a, b, c, dif, d1, d2, d3, count=0;

    scanf("%lf%lf%lf%lf", &a, &b, &c, &dif);

    

    d1 = abs(a-c);

    d2 = abs(a-b);

    d3 = abs(b-c);

    

    if(d1<=dif)

        count=1;

    if(d2<=dif && d3<=dif)

        count=1;

    

    if(count==0)

        printf("No\n");

    else

        printf("Yes\n");

    

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits//stdc++.h>

using namespace std;

int main()

{

    int a,b,c,i,j,d;

    cin>>a>>b>>c>>d;

    if(abs(a-c)<=d)

        cout<<"Yes"<<endl;

    else if(abs(a-b)<=d && abs(b-c)<=d)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>



int main()

{

    double a, b, c, dif, d1, d2, d3, count=0;

    scanf("%lf%lf%lf%lf", &a, &b, &c, &dif);

    

    d1 = abs(a-c);

    d2 = abs(a-b);

    d3 = abs(b-c);

    

    if(d1<=dif)

        count=1;

    if(d2<=dif && d3<=dif)

        count=1;

    

    if(count==0)

        printf("No\n");

    else

        printf("Yes\n");

    

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int a,b,c,d;

    cin >> a >> b >> c >> d;



    if (fabs(a-b)<=d && fabs(b-c)<=d || fabs(a-c)<=d)

    {

        cout<<"Yes";

    }

    else

    {

        cout<<"No";

    }



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>



int main()

{

    double a, b, c, dif, d1, d2, d3, count=0;

    scanf("%lf%lf%lf%lf", &a, &b, &c, &dif);

    

    d1 = abs(a-c);

    d2 = abs(a-b);

    d3 = abs(b-c);

    

    if(d1<=dif)

        count=1;

    if(d2<=dif && d3<=dif)

        count=1;

    

    if(count==0)

        printf("No\n");

    else

        printf("Yes\n");

    

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#include<bits/stdc++.h>

using namespace std;

main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    long long i,j,k,l,m,n,o,p,q;

    while(cin>>m>>n>>o>>p)



    {

        if(abs(m-o)<=p)

            cout<<"Yes"<<endl;

        else  if(abs(m-n)<=p&&abs(n-o)<=p)

            cout<<"Yes"<<endl;

        else

            cout<<"No"<<endl;

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

int main()

{

    int a,b,c,d,t;

    scanf("%d%d%d%d",&a,&b,&c,&d);

    if(abs(c-a)<=d)

    {

        t=1;

    }

    else if(abs(a-b)<=d)

    {

        if(abs(b-c)<=d)

            t=1;

            else t=0;

    }

    else t=0;

    if(t==1)

        printf("Yes");

    else printf("No");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

   int a,b,c,d;

   cin>>a>>b>>c>>d;

   if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))

    cout<<"Yes\n";

   else cout<<"No\n";

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

int main()

{

    int a,b,c,d,t;

    scanf("%d%d%d%d",&a,&b,&c,&d);

    if(abs(c-a)<=d)

    {

        t=1;

    }

    else if(abs(a-b)<=d)

    {

        if(abs(b-c)<=d)

            t=1;

            else t=0;

    }

    else t=0;

    if(t==1)

        printf("Yes");

    else printf("No");

    return 0;

}


// Fastest known solution for this problem: