stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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";

}


// Faster C++ solution for the same problem (measured speedup: 5.285965553623063x):
#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;

}
// Slower C++ solution:
#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");

}

// Faster C++ solution for the same problem (measured speedup: 5.216759952035779x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.289718703525659x):
#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;

}
// Slower C++ solution:
#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;

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.225194798834743x):
#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;

}
// Slower C++ solution:
#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 ;

}

// Faster C++ solution for the same problem (measured speedup: 5.289106979658417x):
#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;

}
// Slower C++ solution:
#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"; 

}

// Faster C++ solution for the same problem (measured speedup: 5.342814030615001x):
#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;

}
// Slower C++ solution:
/*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));

}

// Faster C++ solution for the same problem (measured speedup: 5.36304639062033x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.370727018044198x):
#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;

}
// Slower C++ solution:
#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");

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.362900423827991x):
#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;

}
// Slower C++ solution:
//#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.282448825560753x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.1119779394291325x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.1197898941831526x):
#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;

}
// Slower C++ solution:
#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;

	}

}

// Faster C++ solution for the same problem (measured speedup: 3.2589106306367244x):
#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:;

	}

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.232838624755903x):
#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;

}
// Slower C++ solution:
#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);

	}

 } 

// Faster C++ solution for the same problem (measured speedup: 5.166408951503379x):
#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;

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

#include<sstream>

#include<string>

#include<string.h>

#include<algorithm>

#include<stdio.h>

#include<math.h>

#include<vector>

#include<queue> 

#include<map>

#include<set>

#include<stack>

#define debug(a) cout << "*" << a << "*" << endl

using namespace std;

typedef long long ll; 

ll a, b, c, d, mx;

ll gcd(ll a, ll b)

{

	return b == 0 ? a : gcd(b, a % b);

}

int main()

{

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

	{

		mx = c * d / gcd(max(c, d), min(c, d));

		a--;

		printf("%lld\n", b - a - b / c - b / d + a / c + a / d + b / (mx) - a / (mx));

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.166232364207981x):
#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;

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

using namespace std;

typedef long long int lint;



int main(){

    lint a, b, c, d;

    

    

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

    lint ekok = (c*d)/__gcd(c,d);

    lint c_bolum_a = (a-1)/c;

    lint d_bolum_a = (a-1)/d;

    lint cd_bolum_a = (a-1)/ekok;

    lint c_bolum_b = b/c;

    lint d_colum_b = b/d;

    lint cd_bolum_b = b/ekok;

    

    lint res = -c_bolum_a-d_bolum_a+c_bolum_b+d_colum_b+cd_bolum_a- cd_bolum_b;

    cout << b-a+1-res;



    return 0;

}


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

int main()

{long long int a,b,c,d,e,s,x,y,z,m;

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

   { int h(long long int q,long long int p);

   x=b/c-(a-1)/c;

    y=b/d-(a-1)/d;

    e=h(c,d);

    m=c*d/e;

    z=b/m-(a-1)/m;

    s=b-a+1-x-y+z;

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

    

   }

}

 int h(long long int q,long long int p)

{if(q%p==0)return(p);

else return (h(p,q%p));

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

using namespace std;

typedef long long int lint;



int main(){

    lint a, b, c, d;

    

    

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

    lint ekok = (c*d)/__gcd(c,d);

    lint c_bolum_a = (a-1)/c;

    lint d_bolum_a = (a-1)/d;

    lint cd_bolum_a = (a-1)/ekok;

    lint c_bolum_b = b/c;

    lint d_colum_b = b/d;

    lint cd_bolum_b = b/ekok;

    

    lint res = -c_bolum_a-d_bolum_a+c_bolum_b+d_colum_b+cd_bolum_a- cd_bolum_b;

    cout << b-a+1-res;



    return 0;

}


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

#include<cmath>

#include<cstring>

using namespace std;



long long gcd(long long a,long long b)

{

    return !b?a:gcd(b,a%b);

}



long long lms(long long  a,long long  b)

{

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

}



int main()

{

    long long a,b,c,d,nc=0;

    //long long i,j;

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

    nc=0;

    long long Lms=lms(c,d);

    if(a%c==0) nc++;

    //if(b%c==0) nc++;

    if(a%d==0) nc++;

    //if(b%d==0) nc++;

    nc+=(b/c-a/c);

    nc+=(b/d-a/d);

    if(a%Lms==0) nc--;

    //if(b%Lms==0) nc--;

    nc-=(b/Lms-a/Lms);

    printf("%lld",b-a+1-nc);}

}