stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<vector>

#include<cstring>



using namespace std;



int n,x,y,siz[200001],fa[200001],maxs[200001],maxp[200001],mins[200001],minp[200001],maxl[200001],minn;

long long ans;

vector<int> point[200001];

char str[200001];



void dfs1(int u,bool check){

	siz[u]=str[u]-'0';

	for(int v:point[u])if(v!=fa[u]){

		fa[v]=u;

		dfs1(v,true);

		siz[u]+=siz[v],maxs[u]=max(maxs[u],maxs[v]+1);

		if(mins[v]<0x7f7f7f7f)mins[u]=min(mins[u],maxs[v]+1);

	}

	if(point[u].size()==check)maxs[u]=0,mins[u]=str[u]-'0'?0:0x7f7f7f7f;else if(str[u]-'0')mins[u]=min(mins[u],maxs[u]);

}



void dfs2(int u,bool check){

	maxp[u]=max(maxp[u],check+maxp[fa[u]]);

	if(check)maxl[u]=max(maxl[u],maxp[u]-1);

	int mx=-1;for(int v:point[u])if(v!=fa[u])maxp[v]=max(maxp[v],mx+2),mx=max(mx,maxs[v]);

	mx=-1;for(int i=point[u].size()-1;~i;--i){int v=point[u][i];if(v!=fa[u])maxp[v]=max(maxp[v],mx+2),mx=max(mx,maxs[v]);}

	for(int v:point[u])if(v!=fa[u])dfs2(v,true);

}



int main(){

	memset(mins,0x7f,sizeof(mins)),memset(minp,0x7f,sizeof(minp));

	scanf("%d",&n);for(int i=1;i<n;++i)scanf("%d%d",&x,&y),point[x].push_back(y),point[y].push_back(x);scanf("%s",str+1);

	dfs1(1,false),dfs2(1,false);

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

		if(str[i]-'0')minn=0;else minn=min(mins[i],siz[i]==siz[1]?2147483647:maxp[i]);

		int d=max(maxs[i],maxp[i])-1;for(int v:point[i])if(v!=fa[i])d=min(d,maxl[v]+1);else d=min(d,maxs[i]+1);

		if(d>=minn)ans+=d-minn+1;

	}

	printf("%lld",ans+1);

}

// Faster C++ solution for the same problem (measured speedup: 1.287038512525692x):
#include <bits/stdc++.h>

using namespace std;



vector<int> nei[200005];

int n;

int lt3[200005];// <3 (less than 3)

int sz[200005],mx[200005];

long long ans=0;



void precalc(int now,int lst){

	if(lt3[now]){

		sz[now]++;

	}

	for(int i=0;i<nei[now].size();i++){

		if(nei[now][i]!=lst){

			precalc(nei[now][i],now);

			sz[now]+=sz[nei[now][i]];

			mx[now]=max(mx[now],mx[nei[now][i]]+1);

		}

	}

}



void dfs(int now,int lst,int mxx){

	int mx1=mxx,mx2=0;

	if(lt3[now]){

		for(int i=0;i<nei[now].size();i++){

			if(nei[now][i]!=lst){

				mx2=max(mx2,mx[nei[now][i]]+1);

				if(mx1<mx2){

					swap(mx1,mx2);

				}

			}

		}

		ans+=min(mx1-1,mx2+1)+1;

	}else{

		int l=1e9;

		if(sz[1]!=sz[now]){

			l=mxx;

		}

		for(int i=0;i<nei[now].size();i++){

			if(nei[now][i]!=lst){

				mx2=max(mx2,mx[nei[now][i]]+1);

				if(mx1<mx2){

					swap(mx1,mx2);

				}

				if(sz[nei[now][i]]){

					l=min(l,mx[nei[now][i]]+1);

				}

			}

		}

		ans+=max(0,min(mx1-1,mx2+1)-l+1);

	}

	for(int i=0;i<nei[now].size();i++){

		if(nei[now][i]!=lst){

			dfs(nei[now][i],now,mx[nei[now][i]]==mx1-1?mx2+1:mx1+1);

		}

	}

}



int main(){

	scanf("%d",&n);

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

		int a,b;

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

		nei[a].push_back(b);

		nei[b].push_back(a);

	}

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

		scanf("%1d",lt3+i);

	}

	precalc(1,0);

	dfs(1,0,0);

	printf("%lld\n",ans+1);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

using namespace std;



int main()

{

	int a, b;

	cin>>a>>b;

	cout<<ceil(double(a+b)/2);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.308698403355161x):
#include<stdio.h>



int main()

{

    int a,b,x;

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

    x=(a+b)/2;

    if((a+b)%2==0)

    {

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

    }

    else

    {

        x+=1;

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

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    double a,b,c;

    cin>>a>>b;

    c=a+b;

    c=ceil(c/2);

    cout<<c;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.357708777867707x):
#include<stdio.h>



int main()

{

    int a,b,x;

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

    x=(a+b)/2;

    if((a+b)%2==0)

    {

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

    }

    else

    {

        x+=1;

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

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

using namespace std;

int main()

{

    int a,b;

    float av;

    cin>>a>>b;

    av=(a+b)/2.0;

    cout<<ceil(av)<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.316796409388566x):
#include<stdio.h>



int main()

{

    int a,b,x;

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

    x=(a+b)/2;

    if((a+b)%2==0)

    {

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

    }

    else

    {

        x+=1;

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

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>



#define C 300000

using namespace std;



int main() {

    int n, q;

    int c[300000], query[100000];

    bool has_c[C+1];

    cin >> n >> q;

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

        cin >> c[i];

    }

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

        cin >> query[i];

    }

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

        has_c[i] = false;

    }

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

        has_c[c[i]] = true;

    }

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

        int max_r = -1;

        for (int r=query[i]-1; r>=0; r--) {

            for (int k=0; true; k++) {

                int x = k*query[i]+r;

                if (x > C) {

                    break;

                }

                if (has_c[x]) {

                    max_r = max(r, max_r);

                    break;

                }

            }

            if (max_r >= 0) {

                break;

            }

        }

        cout << max_r << endl;

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.170405304500449x):
#include <cstdio>

#include <algorithm>



#define C 300000

using namespace std;



int main() {

    int n, q;

    int c[300000], query[100000];

    bool has_c[C+1];

    scanf("%d%d", &n, &q);

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

        scanf("%d", &c[i]);

    }

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

        scanf("%d", &query[i]);

    }

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

        has_c[i] = false;

    }

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

        has_c[c[i]] = true;

    }

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

        int max_r = -1;

        for (int r=query[i]-1; r>=0; r--) {

            for (int k=0; true; k++) {

                int x = k*query[i]+r;

                if (x > C) {

                    break;

                }

                if (has_c[x]) {

                    max_r = max(r, max_r);

                    break;

                }

            }

            if (max_r >= 0) {

                break;

            }

        }

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

    }

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

long long n,a,b,x,s,ans;

int main(){

	cin>>n>>a>>b>>s;

	for(int i=2;i<=n;i++)

	{

		cin>>x;

		ans+=min((x-s)*a,b);

		s=x;

	}

	cout<<ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.627655125182323x):
#include<stdio.h>

int main()

{

    long long int N,A,B,a[100005],i,sum=0;

    scanf("%lld%lld%lld",&N,&A,&B);

    for(i=0;i<N;i++)

        scanf("%lld",&a[i]);

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

       {

        if((a[i+1]-a[i])*A<B)

        sum+=(a[i+1]-a[i])*A;

        else

            sum+=B;

       }

       printf("%lld",sum);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int N=100000+10;

long long x[N],a,b,n,f[N]={0},ans=0;

int main(){

    scanf("%ld%ld%ld",&n,&a,&b);

    for(int i=1;i<=n;i++)

        scanf("%ld",&x[i]);

    for(int i=1;i<=n-1;i++)

        f[i]+=min((x[i+1]-x[i])*a,b);

    for(int i=1;i<=n-1;i++)

     ans+=f[i]; 

    cout<<ans;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.629724070869559x):
#include<stdio.h>

int main()

{

    long long int N,A,B,a[100005],i,sum=0;

    scanf("%lld%lld%lld",&N,&A,&B);

    for(i=0;i<N;i++)

        scanf("%lld",&a[i]);

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

       {

        if((a[i+1]-a[i])*A<B)

        sum+=(a[i+1]-a[i])*A;

        else

            sum+=B;

       }

       printf("%lld",sum);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

long long g[1000100];

int main()

{

	long long n,a,b,ans;

	cin>>n>>a>>b;

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

		cin>>g[j];

	for(int i=1;i<n;i++)

	{

		if((g[i+1]-g[i])*a>=b)ans+=b;

		else if((g[i+1]-g[i])*a<b)ans+=(g[i+1]-g[i])*a;

	}

	cout<<ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.668159670850738x):
#include<stdio.h>

int main()

{

    long long int N,A,B,a[100005],i,sum=0;

    scanf("%lld%lld%lld",&N,&A,&B);

    for(i=0;i<N;i++)

        scanf("%lld",&a[i]);

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

       {

        if((a[i+1]-a[i])*A<B)

        sum+=(a[i+1]-a[i])*A;

        else

            sum+=B;

       }

       printf("%lld",sum);

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<string>

#include<algorithm> 

using namespace std;

long long ans=0;

int main()

{

	long long n,a,b,x,y;

	cin>>n>>a>>b;

	cin>>y;

	for(long long i=2;i<=n;i++)

	{

		cin>>x;

		if((x-y)*a>=b) ans+=b;

		else ans+=((x-y)*a);

		y=x;

	}

	cout<<ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.667559768089879x):
#include<stdio.h>

int main()

{

    long long int N,A,B,a[100005],i,sum=0;

    scanf("%lld%lld%lld",&N,&A,&B);

    for(i=0;i<N;i++)

        scanf("%lld",&a[i]);

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

       {

        if((a[i+1]-a[i])*A<B)

        sum+=(a[i+1]-a[i])*A;

        else

            sum+=B;

       }

       printf("%lld",sum);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<cstdio>

#include<string>

//#include<string>

//#include<sstream>

#include<iomanip>

using namespace std;

int main() {

	long long  n,a,b;

	long long x[100000],i;

	scanf("%lld%lld%lld",&n,&a,&b);

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

		scanf("%lld",&x[i]);

	}

	long long sum=0;

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

		sum+=min((x[i]-x[i-1])*a,b);

	}

	printf("%lld\n",sum);

}

// Faster C++ solution for the same problem (measured speedup: 4.687825764189856x):
#include<stdio.h>

int main()

{

    long long int N,A,B,a[100005],i,sum=0;

    scanf("%lld%lld%lld",&N,&A,&B);

    for(i=0;i<N;i++)

        scanf("%lld",&a[i]);

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

       {

        if((a[i+1]-a[i])*A<B)

        sum+=(a[i+1]-a[i])*A;

        else

            sum+=B;

       }

       printf("%lld",sum);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<math.h>

using namespace std;

long long a[100005];

int main()

{

	long long n,a1,b,minsum=0;

	cin>>n>>a1>>b;

	for(int i=1;i<=n;i++)

	cin>>a[i];

	sort(a+1,a+n+1);

	for(int i=1;i<n;i++)

	minsum+=min(a1*(a[i+1]-a[i]),b);

	cout<<minsum<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2093722791824515x):
#include<stdio.h>

#include<algorithm>

#define N (100010)

typedef long long LL;

int x[N],d[N];

int main(){

	int n,a,b;

	LL ans=0;

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

	for (int i=1;i<=n;i++) scanf("%d",x+i);

	for (int i=2;i<=n;i++) d[i]=x[i]-x[i-1];

	std::sort(d+2,d+n+1);

	for (int i=n;i>1;i--){

		if (1ll*d[i]*a>1ll*b){

			ans+=b;

		}

		else {

			for (int j=2;j<=i;j++){

				ans+=1ll*a*d[j];

			}

			break;

		}

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include<iostream> 

using namespace std;

int main()

{

	long long n,a,b,x,y,tir=0;;

	cin>>n>>a>>b>>x;

	n--;

	while(n--){

		cin>>y;

		if((y-x)*a>b)tir+=b;

		else tir+=(y-x)*a;

		x=y;

	}cout<<tir;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.198260423916113x):
#include<stdio.h>

#include<algorithm>

#define N (100010)

typedef long long LL;

int x[N],d[N];

int main(){

	int n,a,b;

	LL ans=0;

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

	for (int i=1;i<=n;i++) scanf("%d",x+i);

	for (int i=2;i<=n;i++) d[i]=x[i]-x[i-1];

	std::sort(d+2,d+n+1);

	for (int i=n;i>1;i--){

		if (1ll*d[i]*a>1ll*b){

			ans+=b;

		}

		else {

			for (int j=2;j<=i;j++){

				ans+=1ll*a*d[j];

			}

			break;

		}

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;

typedef long long ll;

int x[N];





int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,a,b; scanf("%d%d%d",&n,&a,&b);

	for (int i=1;i<=n;i++) scanf("%d",&x[i]);

	

	ll ans=0;

	for (int i=2;i<=n;i++)

	{

		ans+=min(1ll*(x[i]-x[i-1])*a,1ll*b);

	}

	cout<<ans<<endl;

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.204852992134926x):
#include<stdio.h>

#include<algorithm>

#define N (100010)

typedef long long LL;

int x[N],d[N];

int main(){

	int n,a,b;

	LL ans=0;

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

	for (int i=1;i<=n;i++) scanf("%d",x+i);

	for (int i=2;i<=n;i++) d[i]=x[i]-x[i-1];

	std::sort(d+2,d+n+1);

	for (int i=n;i>1;i--){

		if (1ll*d[i]*a>1ll*b){

			ans+=b;

		}

		else {

			for (int j=2;j<=i;j++){

				ans+=1ll*a*d[j];

			}

			break;

		}

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long LL;

int N,A,B,X[100010];



int main()

{

	scanf("%d%d%d",&N,&A,&B);

	for (int i=1;i<=N;i++)scanf("%d",&X[i]);

	LL ans=0;

	for (int i=2;i<=N;i++)

	ans+=min(LL(A)*LL(X[i]-X[i-1]),LL(B));

	cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.204430764930099x):
#include<stdio.h>

#include<algorithm>

#define N (100010)

typedef long long LL;

int x[N],d[N];

int main(){

	int n,a,b;

	LL ans=0;

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

	for (int i=1;i<=n;i++) scanf("%d",x+i);

	for (int i=2;i<=n;i++) d[i]=x[i]-x[i-1];

	std::sort(d+2,d+n+1);

	for (int i=n;i>1;i--){

		if (1ll*d[i]*a>1ll*b){

			ans+=b;

		}

		else {

			for (int j=2;j<=i;j++){

				ans+=1ll*a*d[j];

			}

			break;

		}

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100000

#define hlq 1000000007

#define pii pair<int,int>



using namespace std;

int d[MAXN+80];

long long ans,a,b;

int main()

{

	int n,i;

	scanf("%d",&n);

	cin>>a>>b;

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

		scanf("%d",d+i);

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

		ans+=min(a*(d[i+1]-d[i]),b);

	cout<<ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.22711310156457x):
#include<stdio.h>

#include<algorithm>

#define N (100010)

typedef long long LL;

int x[N],d[N];

int main(){

	int n,a,b;

	LL ans=0;

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

	for (int i=1;i<=n;i++) scanf("%d",x+i);

	for (int i=2;i<=n;i++) d[i]=x[i]-x[i-1];

	std::sort(d+2,d+n+1);

	for (int i=n;i>1;i--){

		if (1ll*d[i]*a>1ll*b){

			ans+=b;

		}

		else {

			for (int j=2;j<=i;j++){

				ans+=1ll*a*d[j];

			}

			break;

		}

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<math.h>

using namespace std;

long long a[100005];

int main()

{

	long long n,a1,b,minsum=0;

	cin>>n>>a1>>b;

	for(int i=1;i<=n;i++)

	cin>>a[i];

	sort(a+1,a+n+1);

	for(int i=1;i<n;i++)

	minsum+=min(a1*(a[i+1]-a[i]),b);

	cout<<minsum<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.218398415508878x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include<iostream> 

using namespace std;

int main()

{

	long long n,a,b,x,y,tir=0;;

	cin>>n>>a>>b>>x;

	n--;

	while(n--){

		cin>>y;

		if((y-x)*a>b)tir+=b;

		else tir+=(y-x)*a;

		x=y;

	}cout<<tir;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.207267307035992x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#include <cstdlib>

#include <set>

#include <queue>

using namespace std;



#define X first

#define Y second

#define N 100010

typedef long long ll;

typedef pair<int,int> pii;

const int Mod=1000000007;



const double INF=1e18;

typedef long long ll;

int x[N];





int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	

	int n,a,b; scanf("%d%d%d",&n,&a,&b);

	for (int i=1;i<=n;i++) scanf("%d",&x[i]);

	

	ll ans=0;

	for (int i=2;i<=n;i++)

	{

		ans+=min(1ll*(x[i]-x[i-1])*a,1ll*b);

	}

	cout<<ans<<endl;

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.213871298016761x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long LL;

int N,A,B,X[100010];



int main()

{

	scanf("%d%d%d",&N,&A,&B);

	for (int i=1;i<=N;i++)scanf("%d",&X[i]);

	LL ans=0;

	for (int i=2;i<=N;i++)

	ans+=min(LL(A)*LL(X[i]-X[i-1]),LL(B));

	cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.213448339230449x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include<set>

#include<map>

#include<stack>

#include<queue>

#include<deque>

#include<cmath>

#include<cstdio>

#include<cctype>

#include<string>

#include<vector>

#include<cstdlib>

#include<cstring>

#include<sstream>

#include<iostream>

#include<algorithm>

#define MAXN 100000

#define hlq 1000000007

#define pii pair<int,int>



using namespace std;

int d[MAXN+80];

long long ans,a,b;

int main()

{

	int n,i;

	scanf("%d",&n);

	cin>>a>>b;

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

		scanf("%d",d+i);

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

		ans+=min(a*(d[i+1]-d[i]),b);

	cout<<ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.236169976926869x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



typedef long long LL;



const int N = 1e5 + 10;

int x[N];



int main() {

    int n, a, b;

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

    for (int i = 0; i < n; i++) scanf("%d", x + i);

    LL ans = 0;

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

        ans += min(1ll * (x[i] - x[i-1]) * a, (LL)b);

    }

    printf("%lld\n", ans);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.1960705670272995x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;

#define LL long long



const LL MOD = 1e9 + 7;

const int N = 200005;



LL n, A, B, in[N];



int main()

{

    while(cin >> n >> A >> B){

        for(int i=0;i<n;i++) cin >> in[i];

        sort(in, in + n);

        LL mn = 0;

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

            LL dis = in[i] - in[i - 1];

            LL x = dis * A;

            if(x < B) mn += x;

            else mn += B;

        }

        cout << mn << '\n';

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.220660515776363x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
// In the name of Allah the Most Merciful.



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



int main(void)

{

    ll n , a , b;

    cin >> n >> a >> b;



    ll ar[n];



    for(int i=0;i<n;i++)cin >> ar[i];



    ll ans = 0;



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



        ll temp = ar[i+1] - ar[i];

        ans+=min(temp*a , b);

    }



    cout << ans << endl;



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.217090160228456x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define debug(x) cout << #x << " = " << x << endl

#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)

#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)



using namespace std;



typedef long long ll;

typedef long double ld;

typedef pair<int, int> ii;



const int MAX = 1e5 + 5;

ll arr[MAX];

ll n, a, b;



int main() {

	scanf("%lld %lld %lld", &n, &a, &b);

	fori(i, 1, n + 1) {

		scanf("%lld", arr + i);

	}



	ll ans = 0;

	fori(i, 2, n + 1) {

		ans += min((arr[i] - arr[i - 1]) * a, b);

	}



	printf("%lld\n", ans);



	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.195369038833451x):
#include<cstdio>

#include<algorithm>

using namespace std;



int arr[100005];

int main(){

    int N, A, B;

    scanf("%d%d%d",&N,&A,&B);

    long long ans = 0;

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

        scanf("%d",&arr[i]);

    }

    sort(arr,arr+N);

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

        ans += min(1ll*abs(arr[i]-arr[i-1])*A,1ll*B);

    }

    printf("%lld\n",ans);

    return 0;

}