stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

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

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

#define sl(n) scanf("%lld", &n);

#define si(n) scanf("%d", &n);

#define RepAll(a) for(auto x: a)

#define cout(ans) cout << ans << endl;

typedef long long ll;

/**

 *    This code has been written by YueGuang, feel free to ask me question. Blog: http://www.yx.telstudy.xyz

 *    created:

 */

 const int mod = 1e9+7;

using namespace std;

//求解所有能组成的矩形的和再取mod

/*

    x1,y1 x5,y5

 xi -  xj , yl - yk

 xi -  xj) * (yl - yk

*/

#define N 100010

ll x[N], y[N];

ll xx, yy, maxy;

int main(){

    int n, m;



    cin >> n >> m;

  //  long long *x = long long new [n];

   // long long *y = long long new [m];



    REP(i, 0, n){

        cin >> x[i];

        /*if(i == 0){

            minx = x;

            maxx = x;

        }

        minx = min(minx, x);

        maxx = max(maxx, x);

        */

    }

    REP(i, 0, m){

        cin >> y[i];

        /*if(i == 0){

            miny = y;

            maxy = y;

        }

        miny = min(miny, y);

        maxy = max(maxy, y);

        */

    }

    //计算每个边长对面积,类似于边权？

    //cout << (maxx - minx);

    //cout << '\n' <<(maxy - miny);

    //cout << ((maxx - minx)%mod * (maxy - miny)%mod)%mod << '\n';

    //REP(i, 0, m){ }

    //yy = (yy % mod; + (y[i] - y[m - i])% mod) * (m - 2*i) % mod;

    for(int i = 0, j = m-1; j > i; j--, i++){

        yy = (yy +abs (y[i] - y[j]) * (j - i))  % mod;

    }

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

    {   xx = (xx + abs(x[i] - x[j]) * (j - i))  % mod;

     }



cout << xx*yy%mod << '\n';

}

// 9 8 7 6 5


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

long long x[100005];

long long y[100005];

const long long mod = 1e9+7;

int main(){

    int n,m;

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

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

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

    }

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

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

    }

    long long sumx = 0;

    for(int i=0, j=n-1;j>i;i++,j--){

        sumx = (sumx + (x[j]-x[i])*(j-i))%mod;

    }

    long long sumy = 0;

    for(int i=0, j=m-1;j>i;i++,j--){

        sumy = (sumy + (y[j]-y[i])*(j-i))%mod;

    }

    printf("%lld\n",(sumx*sumy)%mod);

    return 0;

}


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

using namespace std;

#define ll long long

#define pb push_back

#define pii pair<int,int>

map<pii,int>m;



vector<int>adjb[200005],adjr[200005];





#define MOD 1000000007

int main()

{





    ll n,m,i,ANS=0,ans=0,ans2=0;

    cin>>n>>m;

    ll ara[n],arb[m];

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

    for(i=0;i<m;i++) cin>>arb[i];

    ll mul=-n+1;

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

    ara[i]=(ara[i]*mul)%MOD;

    mul+=2;

    }



    mul=-m+1;

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

    arb[i]=(arb[i]*mul)%MOD;

    mul+=2;

    }

    for(i=0;i<n;i++) ans=(ans+ara[i])%MOD;

    for(i=0;i<m;i++) ANS=(ANS+(arb[i]*ans)%MOD)%MOD;

    cout<<ANS;











}

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

#define ll long long

using namespace std;

const int MAXN = 1e5 + 7;

const int mod = 1e9 + 7;

ll x[MAXN], y[MAXN];

inline ll add(ll x, ll y) {return (x + y) % mod;}

inline ll mul(ll x, ll y) {return (x * y) % mod;}

int main()

{

    int n, m; scanf("%d%d", &n, &m);

    ll sum = 0;

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

    {

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

        sum = add(sum, mul(x[i] - x[i - 1], mul(i - 1, n - i + 1)));

    }

    ll ans = 0;

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

    {

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

        ans = add(ans, mul(sum, mul(y[i] - y[i - 1], mul(i - 1, m - i + 1))));

    }

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

    return 0;

}

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



using namespace std;



long long MOD = 1000000007;

long long prod(long long a, long long b){

    return (a*b)%MOD;

}



int main(){

    int n, m;

    cin >> n >> m;

    long long vert[n], hori[m];

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

        cin >> vert[one];

    }

    for(int one = 0; one < m; one++){

        cin >> hori[one];

    }



    long long xaxis = 0, yaxis = 0, temp = 0, temp2 = 0, ans = 0;

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

        temp = prod(one, n-one);

        temp2 = vert[one] - vert[one-1];

        temp = prod(temp, temp2);

        xaxis = (xaxis+temp)%MOD;

    }

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

        temp = prod(one, m-one);

        temp2 = hori[one] - hori[one-1];

        temp = prod(temp, temp2);

        yaxis = (yaxis+temp)%MOD;

    }

    ans = prod(xaxis, yaxis);

    cout << ans;

}

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

#include       <map>

#include     <queue>

#include     <cmath>

#include    <cstdio>

#include    <cctype>

#include    <vector>

#include   <cstring>

#include <algorithm>

using namespace std;



typedef long long ll;

const ll mod = 1e9+7;

const double eps = 1e-7;

const int maxn = 1e5+5;



ll fast_pow(ll a,ll b,ll mod){

    ll ans = 1;

    while(b){

        if(b&1)

            ans = ans*a%mod;

        a = a*a%mod;

        b>>=1;

    }

    return ans;

}



int main(){

    ll n, m;

    ll a, x=0, y=0;

    scanf("%lld%lld",&n,&m);



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

        scanf("%lld",&a);

        x = (x+(2*i-n-1)*a)%mod;

    }

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

        scanf("%lld",&a);

        y = (y+(2*i-m-1)*a)%mod;

    }

    printf("%lld\n",x*y%mod);

    return 0;

}



/*



1592794101

989097785





232162543



*/


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

#define ll long long

#define mod 1000000007

using namespace std;

ll x[100000],y[100000];

int main()

{

    ll i,j,k;

    ll n,m;

    ll conx=(ll)0,cony=(ll)0;

    scanf("%lld %lld",&n,&m);

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

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

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

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

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

        conx=(conx+((x[i+1]-x[i])*((i+1)*(n-i-1))%mod)%mod)%mod;

    }

    //prllf("%d %d\n",conx,cony);

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

        cony=(cony+((y[i+1]-y[i])*((i+1)*(m-i-1))%mod)%mod)%mod;

    }

    printf("%lld",(conx*cony)%mod);

}


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

#include       <map>

#include     <queue>

#include     <cmath>

#include    <cstdio>

#include    <cctype>

#include    <vector>

#include   <cstring>

#include <algorithm>

using namespace std;



typedef long long ll;

const ll mod = 1e9+7;

const double eps = 1e-7;

const int maxn = 1e5+5;



ll fast_pow(ll a,ll b,ll mod){

    ll ans = 1;

    while(b){

        if(b&1)

            ans = ans*a%mod;

        a = a*a%mod;

        b>>=1;

    }

    return ans;

}



int main(){

    ll n, m;

    ll a, x=0, y=0;

    scanf("%lld%lld",&n,&m);



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

        scanf("%lld",&a);

        x = (x+(2*i-n-1)*a)%mod;

    }

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

        scanf("%lld",&a);

        y = (y+(2*i-m-1)*a)%mod;

    }

    printf("%lld\n",x*y%mod);

    return 0;

}



/*



1592794101

989097785





232162543



*/


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

using namespace std;

#define pi acos(0.0)

#define ll long long

#define f first

#define s second

#define gap ' '

#define pb push_back

#define mod 1000000007

int main()

{

    ll n,m;

    cin>>n>>m;

    ll x[n+5],y[m+5];

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

    {

        cin>>x[i];

    }

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

    {

        cin>>y[i];

    }

    sort(x,x+n);

    sort(y,y+m);

    ll xx=0;

    ll yy=0;

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

    {

        xx+=(i-(n-1))*x[i]+i*x[i];

        //cout<<xx<<endl;

    }



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

    {

        yy+=(i-(m-1))*y[i]+i*y[i];

    }



    ll ans=((xx%mod)*(yy%mod))%mod;

    cout<<ans;



}


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

#include       <map>

#include     <queue>

#include     <cmath>

#include    <cstdio>

#include    <cctype>

#include    <vector>

#include   <cstring>

#include <algorithm>

using namespace std;



typedef long long ll;

const ll mod = 1e9+7;

const double eps = 1e-7;

const int maxn = 1e5+5;



ll fast_pow(ll a,ll b,ll mod){

    ll ans = 1;

    while(b){

        if(b&1)

            ans = ans*a%mod;

        a = a*a%mod;

        b>>=1;

    }

    return ans;

}



int main(){

    ll n, m;

    ll a, x=0, y=0;

    scanf("%lld%lld",&n,&m);



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

        scanf("%lld",&a);

        x = (x+(2*i-n-1)*a)%mod;

    }

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

        scanf("%lld",&a);

        y = (y+(2*i-m-1)*a)%mod;

    }

    printf("%lld\n",x*y%mod);

    return 0;

}



/*



1592794101

989097785





232162543



*/


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

using namespace std;

typedef long long LL;

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

int main(){

	int n;

	cin>>n;

	int r=0;

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

		int c=0;

		for(int j=1;j<=i;j++)if(i%j==0)c++;

		if(i%2==1&&c==8)r++;

	}

	cout<<r;

	return 0;

}


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

#define N 100005

#define P pair<int,int>

#define int long long

inline int read(){

    int x=0;char ch=getchar();

    for(;ch<48||ch>57;ch=getchar());

    for(;ch>47&&ch<58;ch=getchar())

    x=(x<<1)+(x<<3)+(ch^48);return x;

}

using namespace std;

signed main()

{

    int n=read();

    if(n>=195)puts("5");else

    if(n>=189)puts("4");else

    if(n>=165)puts("3");else

    if(n>=135)puts("2");else

    if(n>=105)puts("1");else

    puts("0");

    return 0;

}

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



using namespace std;



int main(){

	int n;

	cin >> n;

	int ans = 0;

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

		int cnt = 0;

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

			if (i % j == 0)

				cnt++;

		}

		if (cnt == 8)

			ans++;

	}

	cout << ans << endl;

	return 0;

}


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

int main(){

    int c=0,n,l=0,i,j;

    scanf("%d",&n);

    for(i=105;i<=n;i+=2){

        l=0;

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

            if(i%j==0) l++;

        }

        if(l==6) c++;

    }

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

    return 0;

}


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

using namespace std;

long long a,b=0,c=0,d,e[1000001],f[1000001];

int main(){

	cin>>a;

	for(long long i=1;i<=a;i++){

		b=0;

		for(long long j=1;j<=i;j++){

			if(i%j==0&&i%2!=0){					

				b++;

			}

		}

		if(b==8){

			c++;

		}

	}

	cout<<c<<endl;

	return 0;

}

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

int main(){

    int c=0,n,l=0,i,j;

    scanf("%d",&n);

    for(i=105;i<=n;i+=2){

        l=0;

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

            if(i%j==0) l++;

        }

        if(l==6) c++;

    }

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

    return 0;

}


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

#include <iostream>

using namespace std;



int cnt(int x) {

    int c = 0;

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

        if (x % i == 0) {

            c++;

        }

    }

    return c;

}



int main() {

    int n;

    cin >> n;



    int c = 0;

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

        if (cnt(i) == 8) {

            c++;

        }

    }



    cout << c << endl;

}




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



int main() {

    int n;

    scanf("%d", &n);



    int c = 0;

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

        int y = 0;

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

            if (i % j == 0) { 

                y++;

            }

        }

        if (y== 8) {

            c++;

        }

    }



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

}




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

#include <iostream>

using namespace std;



int main() {

    int n;

    cin >> n;



    int c = 0;

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

        int y = 0;

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

            if (i % j == 0) { 

                y++;

            }

        }

        if (y== 8) {

            c++;

        }

    }



    cout << c << endl;

}




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



int main() {

    int n;

    scanf("%d", &n);



    int c = 0;

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

        int y = 0;

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

            if (i % j == 0) { 

                y++;

            }

        }

        if (y== 8) {

            c++;

        }

    }



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

}




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

using namespace std;



int main() {

    int n;

    cin >> n;



    int c = 0;

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

        int y = 0;

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

            if (i % j == 0) { 

                y++;

            }

        }

        if (y== 8) {

            c++;

        }

    }



    cout << c << endl;

}




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



int main() {

    int n;

    scanf("%d", &n);



    int c = 0;

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

        int y = 0;

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

            if (i % j == 0) { 

                y++;

            }

        }

        if (y== 8) {

            c++;

        }

    }



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

}




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

//  AAAAAB.cpp

//  my_programs

//

//  Created by Jiatuo Zou on 7/22/20.

//  Copyright © 2020 Jiatuo Zou. All rights reserved.

//



#include <iostream>



int main()

{

    using namespace std;

    

    int n, m, k, f = 0, books = 0, ans = 0, f2 = 0;

    long long int ab[2][200000], prefixs_sum[2][200001] = {{0}};

    cin >> n >> m >> k;

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

        cin >> ab[0][i];

        prefixs_sum[0][i + 1] += (ab[0][i] + prefixs_sum[0][i]);

        if(prefixs_sum[0][i + 1] > k && f2 == 0){

            f = i;

            f2 = 1;

        }

    }

    if(prefixs_sum[0][n] <= k){

        f = n;

    }

    books = f;

    ans = f;

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

        cin >> ab[1][i];

        prefixs_sum[1][i + 1] += (ab[1][i] + prefixs_sum[1][i]);

    }

    for(int i = f, j = 1; j <= m; ){

        if(prefixs_sum[1][j] > k){

            break;

        }

        if(k - prefixs_sum[0][i] >= prefixs_sum[1][j]){

            j++;

            books++;

        } else if(i > 0 && k - prefixs_sum[0][i] < prefixs_sum[1][j]){

            i--;

            books--;

        }

        ans = max(ans, books);

    }

    cout << ans << endl;

    return 0;

}


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



using namespace std;



typedef long long ll;



const int N=2e5+50;

ll n,m,k,arr[N],brr[N];



int solve(ll val){

    int low=1,high=m,mid,x=0;

    while(low<=high){

        mid=low+(high-low)/2;

        if (brr[mid]<=val){

            x=mid;

            low=mid+1;

        }

        else

            high=mid-1;

    }

    return x;

}



int main()

{

    cin>>n>>m>>k;

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

        cin>>arr[i];

        arr[i]+=arr[i-1];

    }

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

        cin>>brr[i];

        brr[i]+=brr[i-1];

    }

    int ans=0;

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

        if (arr[i]>k)

            break;

        ans=max(ans,solve(k-arr[i])+i);

    }

    cout<<ans;



    return 0;

}


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

using namespace std;



const long long MAXN = 2e5 + 1;

long long n, m, i, j, k, z, a[MAXN], b[MAXN];



int main()

{

	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

    cin >> n >> m >> k;

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

		cin >> a[i], a[i] += a[i - 1];

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

		cin >> b[i], b[i] += b[i - 1];

	z = 0, i = 0, j = m;

	while (a[i] <= k && i <= n)

	{

		while (b[j] > k - a[i])

			--j;

		z = max(z, i + j);

		++i;

	}

	cout << z << '\n';

    return 0;

}

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

using namespace std;

const int MAXN = 2e5 + 1;

int n, m, i, j, k, z;

long a[MAXN], b[MAXN];

signed main()

{

    scanf("%d %d %d", &n, &m, &k);

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

		scanf("%d", &a[i]), a[i] += a[i - 1];

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

		scanf("%d", &b[i]), b[i] += b[i - 1];

	z = 0, i = 0, j = m;

	while (a[i] <= k && i <= n)

	{

		while (b[j] > k - a[i])

			--j;

		if (i + j > z)

			z = i + j;

		++i;

	}

	printf("%d", z);

}

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

using namespace std;

const int MAXN = 2e5 + 1;

int n, m, i, j, k, z;

long long a[MAXN], b[MAXN];

int main()

{

	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

    cin >> n >> m >> k;

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

		cin >> a[i], a[i] += a[i - 1];

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

		cin >> b[i], b[i] += b[i - 1];

	z = 0, i = 0, j = m;

	while (a[i] <= k && i <= n)

	{

		while (b[j] > k - a[i])

			--j;

		z = max(z, i + j);

		++i;

	}

	cout << z;

    return 0;

}

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

using namespace std;

const int MAXN = 2e5 + 1;

int n, m, i, j, k, z;

long a[MAXN], b[MAXN];

signed main()

{

    scanf("%d %d %d", &n, &m, &k);

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

		scanf("%d", &a[i]), a[i] += a[i - 1];

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

		scanf("%d", &b[i]), b[i] += b[i - 1];

	z = 0, i = 0, j = m;

	while (a[i] <= k && i <= n)

	{

		while (b[j] > k - a[i])

			--j;

		if (i + j > z)

			z = i + j;

		++i;

	}

	printf("%d", z);

}

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

#include <cmath>

using namespace std;



int main()

{

	int a, b;

	cin>>a>>b;

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

	return 0;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem: