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

#include<cstdio>

#include<cmath>

using namespace std;

int main()

{

	int a,n[100005],ans;

	scanf("%d",&a);

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

	{

		cin>>n[i];

		ans+=n[i];

	}

	if((ans%2)==0)	cout<<"YES"<<endl;

	else	cout<<"NO"<<endl;

	return 0;

}

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

int main(){

    int n,sum=0,tmp;

    scanf("%d",&n);

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

        scanf("%d",&tmp);

        sum+=tmp;

    }

    if(sum%2==0){

        printf("YES\n");

    }

    else{

        printf("NO\n");

    }

}

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

using namespace std;

int main()

{

	long long n,a[100000]={0},count=0;

	cin>>n;

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

	{

		cin>>a[i];

		count+=a[i];

	}

	if(count%2==0)

	{

		cout<<"YES";

		return 0;

	 } 

	cout<<"NO";

	return 0;

 } 

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

using namespace std;

long long n,a,ans;

int main(){

	scanf("%d",&n);

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

		scanf("%d",&a);

		ans+=a;

	}

	if (ans%2==0) printf("YES\n");

	else printf("NO\n");

	return 0;

} 

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

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

using namespace std;



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

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

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

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

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL) INF;



const int MAX = 200*1000+47;





int main()

{

    int n;

    scanf("%d", &n);

    LL s = 0;

    FOR(i, 0, n)

    {

        int x;

        scanf("%d", &x);

        s += x;

    }

    if (s & 1)printf("NO\n");

    else printf("YES");

    

    

    

    

}




















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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

#include<iostream>

#include<string>

#include<vector>

#include<map>

using namespace std;

#define pb push_back

#define mp make_pair

#define fi first

#define se second



typedef long long ll;

typedef long double ld;

typedef unsigned long long  ull;

typedef vector<int> vi;



struct pp{ll x,y;};



const int base = 1000*1000*1000;

const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

const int inf = (int)1e9;

const int mod = 1e9+7;

ll gcd (ll a, ll b) {

        while (b) {

            a %= b;

            swap (a, b);

        }

        return a;

}



/*

void quickSort(int left, int right) {

      int i = left, j = right;

      pp tmp;

      int pivot = a[(left + right) / 2].x;

      while (i <= j) {

            while (a[i].x < pivot)

                  i++;

            while (a[j].x > pivot)

                  j--;

            if (i <= j) {

                 swap(a[i],a[j]);

                  i++,j--;

            }

      };

    if (left < j)

            quickSort(left, j);

      if (i < right)

            quickSort(i, right);

}*/

ll binpow (ll a, ll n) {

	ll res = 1;

	while (n) {

		if (n & 1)

			res *= a,res %= mod;

		a *= a,a %= mod;

		n >>= 1;

	}

	return res;

}

int main(){

    ll n,x;

    cin>>n;

    ll cnt=0;

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

        cin>>x;

        cnt+=x%2;

    }

    if(cnt%2)cout<<"NO";

    else cout<<"YES";

}


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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

#include <iostream>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <queue>

#include <map>

#include <set>

using namespace std;

#define rg register

#define LL long long

#define __space putchar(' ')

#define __endl putchar('\n')

template <typename qwq> inline void read(qwq & x)

{

    x = 0;

    rg int f = 1;

    rg char c = getchar();

    while (c < '0' || c > '9')

    {

        if (c == '-') f = -1;

        c = getchar();

    }

    while (c >= '0' && c <= '9')

    {

        x = (x << 1) + (x << 3) + (c ^ 48);

        c = getchar();

    }

    x *= f;

}

template <typename qaq> inline void print(qaq x)

{

    if (x < 0)

    {

        putchar('-');

        x = -x;

    }

    if (x > 9) print(x / 10);

    putchar(x % 10 + '0');

}

int even,odd,n,x;

int main()

{

	read(n);

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

	{

		read(x);

		if (x & 1) ++odd;

		else ++even;

	}

	if (odd & 1) printf("NO");

	else printf("YES");

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring>

using namespace std;

int a[100001],ji,ou;

int main()

{

	int n;

	cin>>n;

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

	{

		cin>>a[i];

		if(a[i]%2==0)ou++;

		else ji++;

	}

	if(ji%2==0)

	{

		cout<<"YES";

	}

	else cout<<"NO";

	return 0;

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

using namespace std;

#define rg register

#define ll long long 

inline ll read()

{

    ll x=0,f=1;

    char c=getchar();

    while(c<'0'||c>'9')

    {

        if(c=='-')

        {

            f=-1;

        }

        c=getchar();

    }

    while(c<='9'&&c>='0')

    {

        x=(x<<1)+(x<<3)+(c^48);

        c=getchar();

    }

    return x*f;

}

ll ji,ou;

ll n;

ll x;

int main()

{

	n=read();

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

	{

		x=read();

		if(x%2==0)

		{

			ou++;

		}	

		else if(x%2!=0)

		{

			ji++;

		}	

	}

	while(1)

	{

		if(ji<=1&&ou<=1)

		{

			break;

		}

		if(ji>=2)

		{

			ji-=2;

			ou+=1;

		}

		if(ou>=2)

		{

			ou--;

		}

	}

	if(ji+ou==1)

	{

		cout<<"YES";

		return 0;

	}

	else

	{

		cout<<"NO";

		return 0;

	}

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

using namespace std ;

int n  , ji = 0 , ou = 0 , a[1000001];

int main ()

{

	cin >> n ;

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

	cin >> a[i] ;

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

	{

	     if ( a[i] % 2 == 0 )

	     ou ++ ;

	     else

	     ji ++ ;

	}

	if ( ji % 2 != 0 ) cout << "NO" ;

	else cout << "YES" ;

	return 0 ;

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

#pragma GCC optimize("Ofast", "unroll-loops")

#define ll long long 

#define ull unsigned ll

#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

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

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

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

#define f first

#define s second

#define pii pair<int,int>

#define SQ(x) (x)*(x);

#define ALL(x) (x).begin(), (x).end()

#define pb push_back

#define endl '\n'

using namespace std;



main(){

   int n; cin>>n;

   vector<int> vc(n);

   REP(i,n) cin>>vc[i];

   int ocount=0;

   REP(i,n) if (vc[i]%2) ocount++;

   if (!(ocount%2)) cout<<"YES\n";

   else cout<<"NO\n"; 

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

#include <bits/stdc++.h>

#include <ext/numeric>

using namespace std; using __gnu_cxx::power;

using ll = long long; using ull = unsigned long long; using ld = long double;

const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;

struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.

template<class C> static auto dud(C *x)->decltype(os << *x, 0);

template<class C> static char dud(...);

template<class C> typename enable_if<sizeof dud<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}

template<class C> Dbg &dump(C b, C e) {

    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;

    return *this << ']';

}

template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {

    return dump(begin(x), end(x));

}

template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {

    return dump(begin(x), end(x));

}

template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}

Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }

} dbg;

void err(istringstream *iss) { delete iss; }

template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {

    string name; *iss >> name; if (name.back()==',') name.pop_back();

    dbg << name << " = " << val << "; ", err(iss, args...);

}

#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl

#define cbug(a, args...) if (a) bug(args);

#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));

#define sl(a) int(strlen(a))

#define sz(a) int(a.size())

int T, Q, cn;//}

const int inf = 1000000007, mxn = 100005;



#define yes cout << "YES\n"

#define no cout << "NO\n"

#define YN(x) cout << ((x) ? "YES\n" : "NO\n")



int n, cnt[2];



signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);

    cin >> n;

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

        int a;

        cin >> a;

        ++cnt[a&1];

    }

    YN(!(cnt[1]&1));

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

#include <stack>

using namespace std;



// number of odd numbers is even

// number of even numbers doesn't matter



int main() {

      ios_base::sync_with_stdio(false);

      cin.tie(NULL);

      cout.tie(NULL);



      int N, odd = 0;

      cin >> N;

      int arr[N];

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

            cin >> arr[i];

            if(arr[i]%2 != 0) odd++;

      }



      if(odd%2 == 0) cout << "YES" << endl;

      else cout << "NO" << endl;

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

#include <cmath>

#include <iomanip>

#include <iostream>

#include <list>

#include <map>

#include <set>

#include <sstream>

#include <string>

#include <vector>



#define endl '\n'

#define ull unsigned long long

#define ll long long

#define ul unsigned long

#define ld long double

#define PI 3.14159265359



using namespace std;



int main() {

	ios_base::sync_with_stdio(false);

	cin.tie(nullptr);

	cout.tie(nullptr);

	int t = 1;

	// cin >> t;

	while (t--) {

		int n;

		cin >> n;

		int x, o = 0;

		while (n--) {

			cin >> x;

			if (x & 1) {

				o++;

			}

		}

		cout << (o & 1 ? "NO" : "YES");

	}

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//#pragma GCC optimize("Ofast")

//#pragma GCC optimize ("unroll-loops")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

 

//Tariquzzaman Faisal

//_Faisal101_

//IUT_CSE'19

//190041101

 

#include<iostream>

#include<stdio.h>

#include<vector>

#include<deque>

#include<map>

#include<stack>

#include<queue>

#include<algorithm>

#include<cstring>

#include<climits>

#include<cmath>

#include<iterator>

#include<set>

#define fileOut freopen("out.txt","w",stdout)

#define fileIn freopen("in.txt","r",stdout)

#define testcases ll TC,T; cin >> TC; for(T=1; T<=TC; T++)

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)

#define INFLL 9223372036854775807

#define INF 2147483647

#define pi acos(-1.0)

#define ll long long

#define endll printf("\n")

#define CASE printf("Case %lld: ",T)

#define ff first

#define ss second

#define mem(ara,n) memset(ara,n,sizeof ara)

#define ull unsigned long long

#define max3(a,b,c) max(a,max(b,c))

#define min3(a,b,c) min(a,min(b,c))

#define mid3(a,b,c) min(max(a,b),max(b,c),max(a,b))

#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define min4(a,b,c,d) min(min(a,b),min(c,d))

#define endl '\n'

#define ld long double

 

 

using namespace std;





int main(){

    ll n;

    cin >> n;

    ll x, odds = 0;

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

    {

        cin >> x;

        if(x%2!=0){

            odds++;

        }

    }

    if(odds % 2 == 0){

        cout<<"YES"<<endl;

    }

    else{

        cout<<"NO"<<endl;

    }

    return 0;

}

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



#define endl '\n'



int main()

{

    int n, i, o=0;

    scanf("%d", &n);



    while(n--)

    {

        scanf("%d", &i);

        o+=i&1;

    }



    o&1? printf("NO"): printf("YES");



    return 0;

}


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

using namespace std;

#define MAX_N 10005

int N,M;

int main(){

  while(cin>>N>>M){

    int Min[MAX_N]={},Max[MAX_N]={};

    if(M==0&&N==0)break;

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

      int p,k,id;

      cin>>p>>k;

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

        cin>>id;

        id--;

        if(k==1){

          Min[id]+=p;

        }

        Max[id]+=p;

      }

    }

    int ans=0;

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

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

        if(Max[i]>Min[j])

          ans=max(ans, abs(Max[i]-Min[j]) );

        

        if(Max[j]>Min[i])

          ans=max(ans, abs(Max[j]-Min[i]) );

      }

    }

    cout<<ans+1<<endl;

  }

  return 0;

}

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

using namespace std;

#define MAX_N 10005



int main(){

  while(1){

    int N,M;

    scanf("%d %d",&N,&M);

    if(M==0&&N==0)break;

    vector<int> Min(N,0);

    vector<int> Max(N,0);

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

      int p,k,id;

      scanf("%d %d",&p,&k);

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

        scanf("%d",&id);

        id--;

        if(k==1){

          Min[id]+=p;

        }

        Max[id]+=p;

      }

    }



    int mini=1e9,maxm=-1e9,ans=0;



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



      if(Max[i]>mini)

        ans=max(ans, abs(Max[i]-mini) );

        

      if(maxm>Min[i])

        ans=max(ans, abs(maxm-Min[i]) );



      mini=min(mini,Min[i]);

      maxm=max(maxm,Max[i]);

    }

    cout<<ans+1<<endl;

  }

  return 0;

}

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

using namespace std;

#define MAX_N 10005

int N,M;

int main(){

  while(cin>>N>>M){

    int Min[MAX_N]={},Max[MAX_N]={};

    if(M==0&&N==0)break;

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

      int p,k,id;

      cin>>p>>k;

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

        cin>>id;

        id--;

        if(k==1){

          Min[id]+=p;

        }

        Max[id]+=p;

      }

    }



    int mini=1e9,maxm=-1e9,ans=0;



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



      if(Max[i]>mini)

        ans=max(ans, abs(Max[i]-mini) );

        

      if(maxm>Min[i])

        ans=max(ans, abs(maxm-Min[i]) );



      mini=min(mini,Min[i]);

      maxm=max(maxm,Max[i]);

    }

    cout<<ans+1<<endl;

  }

  return 0;

}

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

using namespace std;

#define MAX_N 10005



int main(){

  while(1){

    int N,M;

    scanf("%d %d",&N,&M);

    if(M==0&&N==0)break;

    vector<int> Min(N,0);

    vector<int> Max(N,0);

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

      int p,k,id;

      scanf("%d %d",&p,&k);

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

        scanf("%d",&id);

        id--;

        if(k==1){

          Min[id]+=p;

        }

        Max[id]+=p;

      }

    }



    int mini=1e9,maxm=-1e9,ans=0;



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



      if(Max[i]>mini)

        ans=max(ans, abs(Max[i]-mini) );

        

      if(maxm>Min[i])

        ans=max(ans, abs(maxm-Min[i]) );



      mini=min(mini,Min[i]);

      maxm=max(maxm,Max[i]);

    }

    cout<<ans+1<<endl;

  }

  return 0;

}

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

#include <cmath>

using namespace std;



int main(){

	double r;

	while(cin >> r , r != 0.0){

		pair<int,int> a(9999999,999999); 

		double pi = M_PI;



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

			for(int k = -1 ; k < 2 ; k+=2){

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

					int nu = (int)( (pi+r*k) * i) + j;

					if(abs(nu - pi*i) <= r*i){

						a = min(a,make_pair(i,nu));

					}

				}

			}

		}

		cout << a.second << "/" << a.first << endl;

	}

}

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

#include <cmath>

using namespace std;



int main(){

	double r;

	while(cin >> r , r != 0.0){

		double pi = M_PI;



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

			for(int k = -1 ; k < 2 ; k+=2){

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

					int nu = (int)( (pi+r*k) * i) + j;

					if(abs(nu - pi*i) <= r*i){

						cout << nu << "/" << i << endl;

						goto exit;

					}

				}

			}

		}

		exit:;

	}

}

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

#include <vector>

#include <set>

#include <algorithm>



using namespace std;



bool DEBUG = false;



long long int gcd(long long int a, long long int b){ 

    if (a == 0) 

        return b;  

    return gcd(b % a, a);  

 } 

 

 long long int lcm(long long int a, long long int b)  

 {  

    return (a*b)/gcd(a, b);  

 }



int main(){

    long long int a, b, c, d;

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

    //for(long long int i=a; i<=b; i++){

    //    if(i%c > 0 && i%d > 0){

    //        cnt++;

    //    }

    //}

    long long int n = b-a+1;

    long long int lcmOfCD = lcm(c,d);

    long long int multiplesInRange = b/c - (a-1)/c + b/d - (a-1)/d;

    long long int repeatedMultiplesInRange = b/lcmOfCD - (a-1)/lcmOfCD;

    if(DEBUG){

        cout <<"lcm of c and d is " <<lcmOfCD <<endl;

        cout <<n <<" numbers in range" <<endl;

        cout <<b/c <<" multiples of " <<c <<" up to " <<b <<endl;

        cout <<(a-1)/c <<" multiples of " <<c <<" up to exc " <<a <<endl;

        cout <<b/c - (a-1)/c <<" multiples of " <<c <<" in range " <<endl <<endl;

        

        cout <<b/d <<" multiples of " <<d <<" up to " <<b <<endl;

        cout <<(a-1)/d <<" multiples of " <<d <<" up to exc " <<a <<endl;

        cout <<b/d - (a-1)/d <<" multiples of " <<d <<" in range " <<endl <<endl;

        

        cout <<multiplesInRange <<" multiples in range" <<endl <<endl;

        

        cout <<b/lcmOfCD <<" common multiples up to " <<b <<endl;

        cout <<(a-1)/lcmOfCD <<" common multiples up to exc " <<a <<endl;

        cout <<repeatedMultiplesInRange <<" repeated multiples in range" <<endl <<endl;

        

        cout <<"guess inc commons = " <<n - multiplesInRange  <<endl;

        cout <<"guess exc commons = " <<n - multiplesInRange + repeatedMultiplesInRange <<endl;

    }

    cout <<n - multiplesInRange + repeatedMultiplesInRange <<endl;

}

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

#include<algorithm>

using namespace std;



long long gcd(long long x,long long y)

{

	if(!y) return x;

	return gcd(y,x%y);

}



int main()

{

	long long a,b,c,d;

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

	long long e=c*d/gcd(c,d);a--;

	long long ans=(b-a+1)-((b-(b%c))-(a-(a%c)))/c-1-((b-(b%d))-(a-(a%d)))/d-1+((b-(b%e))-(a-(a%e)))/e+1;

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

	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;

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

	{

		ll gcd=__gcd(c,d);

		ll lcm=c*d/gcd;

		ll n=b/c-(a-1)/c;

		ll m=b/d-(a-1)/d;

		ll num=n+m-(b/lcm-(a-1)/lcm);

		printf("%lld\n",b-a+1-num);

	}

 } 

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

#include<algorithm>

using namespace std;



long long gcd(long long x,long long y)

{

	if(!y) return x;

	return gcd(y,x%y);

}



int main()

{

	long long a,b,c,d;

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

	long long e=c*d/gcd(c,d);a--;

	long long ans=(b-a+1)-((b-(b%c))-(a-(a%c)))/c-1-((b-(b%d))-(a-(a%d)))/d-1+((b-(b%e))-(a-(a%e)))/e+1;

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

	return 0;

}


// Fastest known solution for this problem: