Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

ll n,t,e;
ll dp[100005];
ll x[100005];
int main(int argc,char* argv[]){
	qi;
	cin>>n>>e>>t;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	
	//dp[i]=min{dp[j]+max{t,2*(x[i]-x[j])}}
	//dp[i]=min{dp[j]+2*(x[i]-x[j])} or dp[i]=min{dp[j]+t} <-easy
	//dp[i]=2*x[i]+min{dp[j]-2*x[j])} 
	ll last=0,mn=-2*x[0];
	for(int i=0;i<n;i++){
		if(2*(x[i]-x[0])<=t){
			dp[i]=t;
			continue;
		}
	
		while(2*(x[i]-x[last+1])>t){
			mn=min(mn,dp[last]-2*x[last+1]);
			last++;
		}
		
		dp[i]=min(mn+2*x[i],dp[last]+t);
	}
	
	cout<<dp[n-1]+e<<endl;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

ll n,t,e;
ll dp[100005];
ll x[100005];
int main(int argc,char* argv[]){
	qi;
	cin>>n>>e>>t;
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	
	//dp[i]=min{dp[j]+max{t,2*(x[i]-x[j])}}
	//dp[i]=min{dp[j]+2*(x[i]-x[j])} or dp[i]=min{dp[j]+t} <-easy
	//dp[i]=2*x[i]+min{dp[j]-2*x[j])} 
	ll last=0,mn=-2*x[0];
	for(int i=0;i<n;i++){
		if(2*(x[i]-x[0])<=t){
			dp[i]=t;
			continue;
		}
	
		while(2*(x[i]-x[last+1])>t){
			mn=min(mn,dp[last]-2*x[last+1]);
			last++;
		}
		
		dp[i]=min(mn+2*x[i],dp[last]+t);
	}
	
	cout<<dp[n-1]+e<<endl;
	return 0;
}



Compiler output:
a.cc:88:6: error: redefinition of 'bool debug'
   88 | bool debug=true;
      |      ^~~~~
a.cc:18:6: note: 'bool debug' previously defined here
   18 | bool debug=true;
      |      ^~~~~
a.cc:96:43: error: redefinition of 'template<class T1, class T2> std::ostream& operator<<(std::ostream&, std::pair<_T1, _T2>)'
   96 | template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
      |                                           ^~~~~~~~
a.cc:26:43: note: 'template<class T1, class T2> std::ostream& operator<<(std::ostream&, std::pair<_T1, _T2>)' previously declared here
   26 | template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
      |                                           ^~~~~~~~
a.cc:100:30: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>)'
  100 | template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
      |                              ^~~~~~~~
a.cc:30:30: note: 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>)' previously declared here
   30 | template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
      |                              ^~~~~~~~
a.cc:109:4: error: redefinition of 'long long int n'
  109 | ll n,t,e;
      |    ^
a.cc:39:4: note: 'long long int n' previously declared here
   39 | ll n,t,e;
      |    ^
a.cc:109:6: error: redefinition of 'long long int t'
  109 | ll n,t,e;
      |      ^
a.cc:39:6: note: 'long long int t' previously declared here
   39 | ll n,t,e;
      |      ^
a.cc:109:8: error: redefinition of 'long long int e'
  109 | ll n,t,e;
      |        ^
a.cc:39:8: note: 'long long int e' previously declared here
   39 | ll n,t,e;
      |        ^
a.cc:110:4: error: redefinition of 'long long int dp [100005]'
  110 | ll dp[100005];
      |    ^~
a.cc:40:4: note: 'long long int dp [100005]' previously declared here
   40 | ll dp[100005];
      |    ^~
a.cc:111:4: error: redefinition of 'long long int x [100005]'
  111 | ll x[100005];
      |    ^
a.cc:41:4: note: 'long long int x [100005]' previously declared here
   41 | ll x[100005];
      |    ^
a.cc:112:5: error: redefinition of 'int main(int, char**)'
  112 | int main(int argc,char* argv[]){
      |     ^~~~
a.cc:42:5: note: 'int main(int, char**)' previously defined here
   42 | int main(int argc,char* argv[]){
      |     ^~~~