#include<bits/stdc++.h>
#define ll long long
#define vlli vector<long long int>
#define vi vector<int>
#define hitAi ios_base::sync_with_stdio(false)
using namespace std;
int main(){
	hitAi;
	string str;
	getline(cin,str);
	ll cnt=0;int a=0,b=0,c=0,flag=0;
	for(ll i=0;str[i]!='\0';i++){
		a=str[i]-'0';
		if(str[i+1]!='\0')
		b=str[i+1]-'0';
		else flag=1;
		if(flag==1) c=a;
		else c=a*10+b;
		if(c%4==0&&(!flag)) cnt+=i+1;
		if(a%4==0) cnt++;
		//cout<<c<<" "<<a<<" "<<cnt<<" ";
		b=0;c=0;a=0;
	}
	cout<<cnt;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define vlli vector<long long int>
#define vi vector<int>
#define hitAi ios_base::sync_with_stdio(false)
using namespace std;
int main(){
	hitAi;
	string str;
	getline(cin,str);
	ll cnt=0;
	ll num=0;
	for(ll i=0;str[i]!='\0';i++){
		num=0;
		for(ll j=i;str[j]!='\0';j++){
			num = num*10+(ll)(str[j]-'0');
			if(num%4==0) cnt++;
			//cout<<num<<" ";
		}
	}
	cout<<cnt;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define vlli vector<long long int>
#define vi vector<int>
#define hitAi ios_base::sync_with_stdio(false)
using namespace std;
int main(){
	hitAi;
	string str;
	getline(cin,str);
	ll cnt=0;int a=0,b=0,c=0;
	for(ll i=0;str[i]!='\0';i++){
		a=str[i]-'0';
		if(str[i+1]!='\0')
		b=str[i+1]-'0';
		if(b==0) c=a;
		else c=a*10+b;
		if(c%4==0&&c>9) cnt+=i+1;
		if(a%4==0) cnt++;
		//cout<<c<<" "<<a<<" "<<cnt<<" ";
		b=0;c=0;a=0;
	}
	cout<<cnt;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define vlli vector<long long int>
#define vi vector<int>
#define hitAi ios_base::sync_with_stdio(false)
using namespace std;
int main(){
	hitAi;
	string str;
	scanf("%[^\n]",str);
	ll cnt=0;
	ll num=0;
	for(ll i=0;str[i]!='\0';i++){
		num=0;
		for(ll j=i;str[j]!='\0';j++){
			num = num*10+(ll)(str[j]-'0');
			if(num%4==0) cnt++;
			//cout<<num<<" ";
		}
	}
	cout<<cnt;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define vlli vector<long long int>
#define vi vector<int>
#define hitAi ios_base::sync_with_stdio(false)
using namespace std;
int main(){
	hitAi;
	string str;
	getline(cin,str);
	ll cnt=0;int a=0,b=0,c=0;
	for(ll i=0;str[i]!='\0';i++){
		a=str[i]-'0';
		if(str[i+1]!='\0')
		b=str[i+1]-'0';
		else b=0;
		c=a*10+b;
		if(c%4==0) cnt+=i+1;
		if(a%4==0) cnt++;
	}
	cout<<cnt;
	return 0;
}


#include<iostream>
using namespace std;
#define long long int int
main()
{
    string s;
    cin>>s;
    int i,l=s.length(),c=0;
    for(i=0;i<l;i++)
    {
        if((((s[i]-48)*10)+(s[i+1]-48))%4==0&&i!=l-1)
        {
            c+=(i+1);
        }
        if((s[i]-48)%4==0)
        {
            c++;
        }
    }
    cout<<c;
}


#include<iostream>
using namespace std;
#define long int int
main()
{
    string s;
    cin>>s;
    int i,l=s.length(),c=0;
    for(i=0;i<l;i++)
    {
        if((((s[i]-48)*10)+(s[i+1]-48))%4==0&&i!=l-1)
        {
            c+=(i+1);
        }
        if((s[i]-48)%4==0)
        {
            c++;
        }
    }
    cout<<c;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll toint(string s)
{
    ll res=0;
    for(ll i =0;i<s.length();i++)
    {
        res+=(s[i]-'0')*pow(10,s.length()-i-1);
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    ll ans=0;
    //cin>>s;
    //scanf("%s",s);
    getline(cin,s);
    //cout<<s.length()<<"\n";
    for(ll i=0;i<s.length();i++)
    {
        for(ll len=1;len<=s.length()-i;len++)
        {
            string x;
            x=s.substr(i,len);//cout<<x<<"\n";
            if(toint(x)%4==0)
                ans++;
        }
    }
    printf("%lld",ans);
}


#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);

const double eps = 0.00000000001;

int main() {
	ll n, l, wm;
	scanf("%lld %lld %lld", &n, &l, &wm);
	l *= 2;
	vl sei, fu;
	rep(i, n) {
		ll x, v;
		scanf("%lld %lld", &x, &v);
		x *= 2;
		if (v > 0) {
			sei.push_back(x);
		}
		else {
			fu.push_back(x);
		}
	}
	sort(all(sei));
	sort(all(fu));
	//DEBUG_VEC(sei); DEBUG_VEC(fu);
	ll ans = 0;
	rep(i, sei.size()) {
		int ok2 = fu.size(), ng2 = -1;
		while (ng2 + 1 < ok2) {
			int mid = (ok2 + ng2) / 2;
			ll left, right, t;
			left = (sei[i] + fu[mid]) / 2;
			right = left + l;
			t = left - sei[i];
			ll d = min(abs(left), abs(right));
			if (d <= wm * t) {
				ok2 = mid;
			}
			else {
				ng2 = mid;
			}
		}
		ans += (int)fu.size() - ok2;
		//DEBUG(ans);
	}
	cout << ans << endl;

}


#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);

const double eps = 0.00000000001;

int main() {
	ll n, l, wm;
	scanf("%lld %lld %lld", &n, &l, &wm);
	l *= 2;
	vl sei, fu;
	rep(i, n) {
		ll x, v;
		scanf("%lld %lld", &x, &v);
		x *= 2;
		if (v > 0) {
			sei.push_back(x);
		}
		else {
			fu.push_back(x);
		}
	}
	sort(all(sei));
	sort(all(fu));
	//DEBUG_VEC(sei); DEBUG_VEC(fu);
	ll ans = 0;
	rep(i, sei.size()) {
		int ok2 = fu.size(), ng2 = -1;
		while (ng2 + 1 < ok2) {
			int mid = (ok2 + ng2) / 2;
			double left, right, t;
			left = (sei[i] + fu[mid]) / 2.0;
			right = left + l;
			t = left - sei[i];
			double d = min(abs(left), abs(right));
			if (d < wm * t) {
				ok2 = mid;
			}
			else {
				ng2 = mid;
			}
		}
		ans += (int)fu.size() - ok2;
		//DEBUG(ans);
	}
	cout << ans << endl;

}


#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);

const double eps = 0.00000000001;

int main() {
	ll n, l, wm;
	scanf("%lld %lld %lld", &n, &l, &wm);
	vl sei, fu;
	rep(i, n) {
		ll x, v;
		scanf("%lld %lld", &x, &v);
		if (v > 0) {
			sei.push_back(x);
		}
		else {
			fu.push_back(x);
		}
	}
	sort(all(sei));
	sort(all(fu));
	//DEBUG_VEC(sei); DEBUG_VEC(fu);
	ll ans = 0;
	rep(i, sei.size()) {
		int ok2 = fu.size(), ng2 = -1;
		while (ng2 + 1 < ok2) {
			int mid = (ok2 + ng2) / 2;
			double d = (sei[i] + fu[mid] + l) / 2.0;
			double t = d - sei[i];
			d = abs(d);
			//DEBUG(d); DEBUG(t);
			if (d < wm * t) {
				ok2 = mid;
			}
			else {
				ng2 = mid;
			}
		}
		ans += (int)fu.size() - ok2;
		//DEBUG(ans);
	}
	cout << ans << endl;

}


#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);

const double eps = 0.00000000001;

int main() {
	ll n, l, wm;
	scanf("%lld %lld %lld", &n, &l, &wm);
	vl sei, fu;
	rep(i, n) {
		ll x, v;
		scanf("%lld %lld", &x, &v);
		if (v > 0) {
			sei.push_back(x);
		}
		else {
			fu.push_back(x);
		}
	}
	sort(all(sei));
	sort(all(fu));
	//DEBUG_VEC(sei); DEBUG_VEC(fu);
	ll ans = 0;
	rep(i, sei.size()) {
		int ok2 = fu.size(), ng2 = -1;
		while (ng2 + 1 < ok2) {
			int mid = (ok2 + ng2) / 2;
			double left, right, t;
			left = (sei[i] + fu[mid]) / 2.0;
			right = left + l;
			t = left - sei[i];
			double d = min(abs(left), abs(right));
			if (d < wm * t) {
				ok2 = mid;
			}
			else {
				ng2 = mid;
			}
		}
		ans += (int)fu.size() - ok2;
		//DEBUG(ans);
	}
	cout << ans << endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
const ll mod=1000000007ll;
int n,m;
ll l;
double w;
bool check(ll a,ll b){
	double x=(a+b)/2.0;
	double y=x-a;
	return (y>0)&&(y>x/w)&&(y>-x/w);
}
vector<ll> v1,v2;
int main() {
	int i,j;
	cin>>n>>l>>w;
	for(i=1;i<=n;i++){
		ll x,v;cin>>x>>v;
		if(v<0) v2.push_back(x+l);
		else v1.push_back(x);
	}
	sort(v2.begin(),v2.end());
	ll ans=0;
	for(auto v:v1){
		int l=0,r=v2.size()-1;
		while(r>l){
			int mid=(l+r)>>1;
			if(check(v,v2[mid])) r=mid;
			else l=mid+1;
		}
		ans+=v2.size()-l;
		if(!check(v,v2[l])) ans--;
	}
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
const ll mod=1000000007ll;
int n,m;
ll l;
double w;
bool check(ll a,ll b){
	double x=(a+b)/2.0;
	double y=x-a;
	return (y>0)&&(y*w>x)&&(y*w>-x);
}
vector<ll> v1,v2;
int main() {
	int i,j;
	cin>>n>>l>>w;
	for(i=1;i<=n;i++){
		ll x,v;cin>>x>>v;
		if(v<0) v2.push_back(x+l);
		else v1.push_back(x);
	}
	if(!v1.size()||!v2.size()){
		cout<<0;
		return 0;
	}
	sort(v2.begin(),v2.end());
	ll ans=0;
	for(auto v:v1){
		int l=0,r=v2.size()-1;
		while(r>l){
			int mid=(l+r)>>1;
			if(check(v,v2[mid])) r=mid;
			else l=mid+1;
		}
		ans+=v2.size()-l;
		if(!check(v,v2[l])) ans--;
	}
	cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n,l,wm; cin>>n>>l>>wm;
    vector<pair<int,int>> v; int c=0;
    vector<int>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<n-1;i++){
        int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();
        if( v[i].second==1 && v[i].first<0){
            for(int j=h;j>=0;j--){
                double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               //cout<<i<<" "<<w<<endl;
                if(abs(w)<=wm && neg[j]<0){
                    c++;
                   // cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                   // if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                   // if(j>0){break;}
            }
            if((abs(w)>wm)){break;}
        }
       // cout<<c<<" "<<(neg.size()-h)<<endl;
        c=c+(neg.size()-h);
      //cout<<h<<endl;
        }

        if( v[i].second==1 && v[i].first>0){
            int h=lower_bound(neg.begin(),neg.end(),v[i].first)-neg.begin();
            for(int j=h;j<neg.size();j++){
                double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));

                if(abs(w)<=wm){
                    c=c+(neg.size()-j);
                    //cout<<i<<" "<<neg.size()-j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;

                    break;
                   // if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                   // if(j>0){break;}
            }
        }
      //cout<<h<<endl;

        }

        /*for(int j=i+1;j<n;j++){
            double w=wm+1;
            //if(x[i]<0){}
            if( ((v[i].second==1 && v[j].second==-1)&&(v[i].first<v[j].first))  || ((v[i].second==-1 && v[j].second==1)&&(v[i].first>v[j].first))){
            w=(( (v[i].second*(0-v[j].first)) - (v[j].second*(0-v[i].first)) + ((v[j].second-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-v[j].first)));
            }
            if(abs(w)<=wm){
                c++;
            if(j<0){j=lower_bound(v.begin(),v.end(),make_pair(0,0))-v.begin();}
            if(i<0 && j>0){break;}
            //cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
            }

        }*/
    }
    //for(int i=0;i<n;i++){cout<<p[i].first<<" "<<p[i].second<<endl;}
    cout<<c;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<int,int>> v; ll c=0;
    vector<int>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<pos.size();i++){
        int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

        if( pos[i]<0){
            for(int j=h;j>=0;j--){
                //cout<<pos[i]<<" "<<neg[j]<<endl;
                if(neg[j]<pos[i]){/*cout<<neg[j]<<" "<<pos[i]<<endl;*/break;}
                double w=((2*(-1*(pos[i]+l/2)))/(neg[j]-pos[i]))-1;
               // double w=(( ((0-neg[j])) - ((-1)*(0-pos[i])) + (((-1)-1)*(l-0.5)) )/((0-pos[i])-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               //cout<<i<<" "<<w<<endl;
               // cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                if(abs(w)<=wm && neg[j]<0){
                    c++;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;

            }
            if((abs(w)>wm && neg[j]<0)){
                //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                break;

            }
        }
        //cout<<c<<" "<<(neg.size()-h)<<endl;
        c=c+(neg.size()-h);
      //cout<<h<<endl;
        }

        if( pos[i]>=0){
            int h=lower_bound(neg.begin(),neg.end(),pos[i])-neg.begin();
            for(int j=h;j<neg.size();j++){
                double w=((2*(-1*(pos[i]+l/2)))/(neg[j]-pos[i]))-1;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                //double w=(( ((0-neg[j])) - ((-1)*(0-pos[i])) + (((-1)-1)*(l-0.5)) )/((0-pos[i])-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));

                if(abs(w)<=wm){
                   // cout<<c<<" "<<(j)<<endl;
                    c=c+(neg.size()-j);
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                    break;
            }
        }
      //cout<<h<<endl;

        }

    }
   // for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i]-l;
            int a=upper_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i]-l;
            int a=upper_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);}
            //cout<<pos[i]<<endl;
        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n,l,wm; cin>>n>>l>>wm;
    vector<pair<int,int>> v; ll c=0;
    vector<int>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<n-1;i++){
        int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();
        if( v[i].second==1 && v[i].first<0){
            for(int j=h;j>=0;j--){
                double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               //cout<<i<<" "<<w<<endl;
                if(abs(w)<=wm && neg[j]<0){
                    c++;
                   // cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                   // if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                   // if(j>0){break;}
            }
            if((abs(w)>wm)){break;}
        }
       // cout<<c<<" "<<(neg.size()-h)<<endl;
        c=c+(neg.size()-h);
      //cout<<h<<endl;
        }

        if( v[i].second==1 && v[i].first>0){
            int h=lower_bound(neg.begin(),neg.end(),v[i].first)-neg.begin();
            for(int j=h;j<neg.size();j++){
                double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));

                if(abs(w)<=wm){
                    c=c+(neg.size()-j);
                    //cout<<i<<" "<<neg.size()-j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;

                    break;
                   // if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                   // if(j>0){break;}
            }
        }
      //cout<<h<<endl;

        }

        /*for(int j=i+1;j<n;j++){
            double w=wm+1;
            //if(x[i]<0){}
            if( ((v[i].second==1 && v[j].second==-1)&&(v[i].first<v[j].first))  || ((v[i].second==-1 && v[j].second==1)&&(v[i].first>v[j].first))){
            w=(( (v[i].second*(0-v[j].first)) - (v[j].second*(0-v[i].first)) + ((v[j].second-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-v[j].first)));
            }
            if(abs(w)<=wm){
                c++;
            if(j<0){j=lower_bound(v.begin(),v.end(),make_pair(0,0))-v.begin();}
            if(i<0 && j>0){break;}
            //cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
            }

        }*/
    }
    //for(int i=0;i<n;i++){cout<<p[i].first<<" "<<p[i].second<<endl;}
    cout<<c;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2-l)-neg.begin();
            c=c+(neg.size()-a);
            //cout<<pos[i]<<endl;
        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2-l)-neg.begin();
            c=c+(neg.size()-a);
               // cout<<(neg.size()-a)<<endl;
            }

        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
   cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(b==1){pos.push_back(a+(l/2));}
        else{neg.push_back(a+(l/2));}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);
            //cout<<pos[i]<<endl;
        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);
                //cout<<a<<endl;
            }

        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
   cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n,l,wm; cin>>n>>l>>wm;
    vector<pair<int,int>> v; int c=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double w=wm+1;
            //if(x[i]<0){}
            if( ((v[i].second==1 && v[j].second==-1)&&(v[i].first<v[j].first))  || ((v[i].second==-1 && v[j].second==1)&&(v[i].first>v[j].first))){
            w=(( (v[i].second*(0-v[j].first)) - (v[j].second*(0-v[i].first)) + ((v[j].second-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-v[j].first)));
            }
            if(abs(w)<=wm){
                c++;
            if(j<0){j=lower_bound(v.begin(),v.end(),make_pair(0,0))-v.begin();}
            if(i<0 && j>0){break;}
            //cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
            }

        }
    }
    cout<<c;

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a+(l/2),b));
        if(b==1){pos.push_back(a+(l/2));}
        else{neg.push_back(a+(l/2));}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            for(int j=h;neg[j]>pos[i];j--){
                //cout<<pos[i]<<" "<<neg[j]<<endl;
                //if(neg[j]<pos[i]){/*cout<<neg[j]<<" "<<pos[i]<<endl;*/break;}
                double w=((2*(-1*(pos[i])))/(neg[j]-pos[i]))-1;
               // cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                if(abs(w)<=wm && neg[j]<0){
                    c++;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;

            }
            if((abs(w)>wm && neg[j]<0)){
                //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                break;

            }
        }
        //cout<<c<<" "<<(neg.size()-h)<<endl;
        c=c+(neg.size()-h);
      //cout<<h<<endl;
        }

        if( pos[i]>=0){
            int y=lower_bound(neg.begin(),neg.end(),pos[i])-neg.begin();
            for(int j=y;j<neg.size();j++){
                double w=((2*(-1*(pos[i])))/(neg[j]-pos[i]))-1;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                if(abs(w)<=wm){
                   // cout<<c<<" "<<(j)<<endl;
                    c=c+(neg.size()-j);
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                    break;
            }
        }
      //cout<<h<<endl;

        }

    }
   // for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i]-l;
            int a=upper_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((-2)*pos[i])/(1-wm))+pos[i]-l;}
            int a=upper_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i];
            int a=upper_bound(neg.begin(),neg.end(),x2-l)-neg.begin();
            c=c+(neg.size()-a);
            //cout<<pos[i]<<endl;
        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i];
            int a=upper_bound(neg.begin(),neg.end(),x2-l)-neg.begin();
            c=c+(neg.size()-a);
               // cout<<(neg.size()-a)<<endl;
            }

        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
   cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<pos.size();i++){
        int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

        if( pos[i]<0){
            for(int j=h;j>=0;j--){
                //cout<<pos[i]<<" "<<neg[j]<<endl;
                if(neg[j]<pos[i]){/*cout<<neg[j]<<" "<<pos[i]<<endl;*/break;}
                double w=((2*(-1*(pos[i]+l/2)))/(neg[j]-pos[i]))-1;
               // double w=(( ((0-neg[j])) - ((-1)*(0-pos[i])) + (((-1)-1)*(l-0.5)) )/((0-pos[i])-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               //cout<<i<<" "<<w<<endl;
               // cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                if(abs(w)<=wm && neg[j]<0){
                    c++;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;

            }
            if((abs(w)>wm && neg[j]<0)){
                //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                break;

            }
        }
        //cout<<c<<" "<<(neg.size()-h)<<endl;
        c=c+(neg.size()-h);
      //cout<<h<<endl;
        }

        if( pos[i]>=0){
            int h=lower_bound(neg.begin(),neg.end(),pos[i])-neg.begin();
            for(int j=h;j<neg.size();j++){
                double w=((2*(-1*(pos[i]+l/2)))/(neg[j]-pos[i]))-1;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                //double w=(( ((0-neg[j])) - ((-1)*(0-pos[i])) + (((-1)-1)*(l-0.5)) )/((0-pos[i])-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));

                if(abs(w)<=wm){
                   // cout<<c<<" "<<(j)<<endl;
                    c=c+(neg.size()-j);
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                    break;
            }
        }
      //cout<<h<<endl;

        }

    }
   // for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a+(l/2));}
        else{neg.push_back(a+(l/2));}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);}
           // cout<<pos[i]<<endl;
        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
   cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n,l,wm; cin>>n>>l>>wm;
    vector<pair<int,int>> v; int c=0;
    vector<int>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<n-1;i++){
        if( v[i].second==1){
            int h=lower_bound(neg.begin(),neg.end(),v[i].first)-neg.begin();
            for(int j=h;j<neg.size();j++){
                double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
                if(abs(w)<=wm){
                    c++;
                   // cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                    if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                   // if(j>0){break;}

            }
        }
        }

        /*if(v[i].first>0 && v[i].second==-1){
            for(int j=0;j<pos.size();j++){
                double w=(( (v[i].second*(0-pos[j])) - ((1)*(0-v[i].first)) + (((1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-pos[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((1)*(0-v[i].first)) + (((1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
                if(w<=wm){
                    c++;
                    cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                    if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                    if(j>0){break;}

            }
        }
        }*/

        /*for(int j=i+1;j<n;j++){
            double w=wm+1;
            //if(x[i]<0){}
            if( ((v[i].second==1 && v[j].second==-1)&&(v[i].first<v[j].first))  || ((v[i].second==-1 && v[j].second==1)&&(v[i].first>v[j].first))){
            w=(( (v[i].second*(0-v[j].first)) - (v[j].second*(0-v[i].first)) + ((v[j].second-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-v[j].first)));
            }
            if(abs(w)<=wm){
                c++;
            if(j<0){j=lower_bound(v.begin(),v.end(),make_pair(0,0))-v.begin();}
            if(i<0 && j>0){break;}
            //cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
            }

        }*/
    }
    //for(int i=0;i<n;i++){cout<<p[i].first<<" "<<p[i].second<<endl;}
    cout<<c;

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n,l,wm; cin>>n>>l>>wm;
    vector<pair<int,int>> v; int c=0;
    vector<int>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<n-1;i++){
        int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();
        if( v[i].second==1 && v[i].first<0){
            for(int j=h;j>=0;j--){
                double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));

                if(abs(w)<=wm && j<0){
                    c++;
                   // cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                   // if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                   // if(j>0){break;}
            }
            if((abs(w)>wm)){break;}
        }
        c=c+(neg.size()-h);
      //cout<<h<<endl;
        }

        if( v[i].second==1 && v[i].first>0){
            int h=lower_bound(neg.begin(),neg.end(),v[i].first)-neg.begin();
            for(int j=h;j<neg.size();j++){
                double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));
               // double w=(( (v[i].second*(0-neg[j])) - ((-1)*(0-v[i].first)) + (((-1)-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-neg[j])));

                if(abs(w)<=wm){
                    c=c+(neg.size()-j);
                    //cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;

                    break;
                   // if(j<0){j=lower_bound(neg.begin(),neg.end(),0)-neg.begin();}
                   // if(j>0){break;}
            }
        }
      //cout<<h<<endl;

        }

        /*for(int j=i+1;j<n;j++){
            double w=wm+1;
            //if(x[i]<0){}
            if( ((v[i].second==1 && v[j].second==-1)&&(v[i].first<v[j].first))  || ((v[i].second==-1 && v[j].second==1)&&(v[i].first>v[j].first))){
            w=(( (v[i].second*(0-v[j].first)) - (v[j].second*(0-v[i].first)) + ((v[j].second-v[i].second)*(l-0.5)) )/((0-v[i].first)-(0-v[j].first)));
            }
            if(abs(w)<=wm){
                c++;
            if(j<0){j=lower_bound(v.begin(),v.end(),make_pair(0,0))-v.begin();}
            if(i<0 && j>0){break;}
            //cout<<i<<" "<<j<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
            }

        }*/
    }
    //for(int i=0;i<n;i++){cout<<p[i].first<<" "<<p[i].second<<endl;}
    cout<<c;

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a+(l/2));}
        else{neg.push_back(a+(l/2));}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i];
            int a=upper_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i];
            int a=upper_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);}
            //cout<<pos[i]<<endl;
        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
   cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a+(l/2),b));
        if(b==1){pos.push_back(a+(l/2));}
        else{neg.push_back(a+(l/2));}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=((-2*pos[i])/(1+wm))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

        if( pos[i]>=0){
            double x2;
            if((1-wm)==0){x2=INT_MAX;}
            else{x2=((2*pos[i])/(1-wm))+pos[i];}
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a+(l/2),b));
        if(b==1){pos.push_back(a+(l/2));}
        else{neg.push_back(a+(l/2));}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=((-2*pos[i])/(1+wm))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

        if( pos[i]>=0){
            double x2;
            if((1-wm)==0){x2=INT_MAX;}
            else{x2=((-2*pos[i])/(1-wm))+pos[i];}
            int a=lower_bound(neg.begin(),neg.end(),x2)-neg.begin();
            c=c+(neg.size()-a);

        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i];
            int a=upper_bound(neg.begin(),neg.end(),x2-l)-neg.begin();
            c=c+(neg.size()-a);
            //cout<<pos[i]<<endl;
        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i];
            int a=upper_bound(neg.begin(),neg.end(),x2-l)-neg.begin();
            c=c+(neg.size()-a);
               // cout<<(neg.size()-a)<<endl;
            }

        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
   cout<<c<<endl;
    ////for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a+(l/2),b));
        if(b==1){pos.push_back(a+(l/2));}
        else{neg.push_back(a+(l/2));}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            for(int j=h;neg[j]>pos[i];j--){
                //cout<<pos[i]<<" "<<neg[j]<<endl;
                //if(neg[j]<pos[i]){/*cout<<neg[j]<<" "<<pos[i]<<endl;*/break;}
                double w=((2*(-1*(pos[i])))/(neg[j]-pos[i]))-1;
               // cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                if(abs(w)<=wm && neg[j]<0){
                    c++;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;

            }
            if((abs(w)>wm && neg[j]<0)){
                //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<endl;
                break;

            }
        }
        //cout<<c<<" "<<(neg.size()-h)<<endl;
        c=c+(neg.size()-h);
      //cout<<h<<endl;
        }

        if( pos[i]>=0){
            int h=lower_bound(neg.begin(),neg.end(),pos[i])-neg.begin();
            for(int j=h;j<neg.size();j++){
                double w=((2*(-1*(pos[i])))/(neg[j]-pos[i]))-1;
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                if(abs(w)<=wm){
                   // cout<<c<<" "<<(j)<<endl;
                    c=c+(neg.size()-j);
                    //cout<<pos[i]<<" "<<neg[j]<<" "<<w<<" "<<v[i].second<<" "<<v[j].second<<" "<<c<<endl;
                    break;
            }
        }
      //cout<<h<<endl;

        }

    }
   // for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
    cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
    int n;
    double l,wm;
    cin>>n>>l>>wm;
    vector<pair<double,double>> v; ll c=0;
    vector<double>pos,neg;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        if(b==1){pos.push_back(a);}
        else{neg.push_back(a);}

    }
    sort(v.begin(),v.end());
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());

    int h=lower_bound(neg.begin(),neg.end(),0)-neg.begin();

    for(int i=0;i<pos.size();i++){

        if( pos[i]<0){
            double x2=(((-2)*pos[i])/(1+wm))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2+l)-neg.begin();
            c=c+(neg.size()-a);

        }

        if( pos[i]>=0){
            double x2;
            if(wm>1){x2=(((2)*pos[i])/(wm-1))+pos[i];
            int a=lower_bound(neg.begin(),neg.end(),x2+l)-neg.begin();
            c=c+(neg.size()-a);}
           // cout<<pos[i]<<endl;
        }

    }
   // cout<<endl;
    //for(int i=0;i<n;i++){cout<<v[i].first<<" "<<v[i].second<<endl;}
   cout<<c<<endl;
    //for(int i=0;i<neg.size();i++){cout<<neg[i]<<endl;}

    return 0;
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else{
            if(b>=0)
            negp.pb(-a);
            if(b<0)
            negn.pb(-a);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2-l;
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2-l;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    pii special=mp(-1e9,0);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else if(a>-l){
            special=mp(a,b);
        }
        else{
            if(b>=0)
            negp.pb(-a);
            if(b<0)
            negn.pb(-a);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    if(special!=mp(-1e9,0)){
        if(special.y==-1){
            ans+=negp.size();
        }
        else{
            ans+=posn.size();
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    pii special=mp(-1e9,0);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else if(a>-l){
            special=mp(a,b);
        }
        else{
            if(b>=0)
            negp.pb(-a-l);
            if(b<0)
            negn.pb(-a-l);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=(it+l)/(w-1)*2-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=(it+l)/(w-1)*2-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    if(special.y!=0){
        if(special.y==-1){
            ans+=negp.size();
        }
        else{
            ans+=posn.size();
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    pii special=mp(-1e9,0);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else if(a>-l){
            special=mp(a,b);
        }
        else{
            if(b>=0)
            negp.pb(-a-l);
            if(b<0)
            negn.pb(-a-l);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    if(special.y!=0){
        if(special.y==-1){
            ans+=negp.size();
        }
        else{
            ans+=posn.size();
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=-l){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else{
            if(b>=0)
            negp.pb(-a);
            if(b<0)
            negn.pb(-a);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else{
            if(b>=0)
            negp.pb(-a);
            if(b<0)
            negn.pb(-a);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2+l;
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2+l;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else{
            if(b>=0)
            negp.pb(-a);
            if(b<0)
            negn.pb(-a);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    pii special=mp(-1e9,0);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else if(a>-l){
            special=mp(a,b);
        }
        else{
            if(b>=0)
            negp.pb(-a-l);
            if(b<0)
            negn.pb(-a-l);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
    printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it*2/(w-1)-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it*2/(w-1)-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    printf("%lld\n",ans);
    if(special.y!=0){
        if(special.y==-1){
            ans+=negp.size();
        }
        else{
            ans+=posn.size();
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    pii special=mp(-1e9,0);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else if(a>-l){
            special=mp(a,b);
        }
        else{
            if(b>=0)
            negp.pb(-a-l);
            if(b<0)
            negn.pb(-a-l);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it*2/(w-1)-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it*2/(w-1)-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    //printf("%lld\n",ans);
    if(special.y!=0){
        if(special.y==-1){
            ans+=negp.size();
        }
        else{
            ans+=posn.size();
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    pii special=mp(-1e9,0);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else if(a>-l){
            special=mp(a,b);
        }
        else{
            if(b>=0)
            negp.pb(-a);
            if(b<0)
            negn.pb(-a);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    if(special.y!=0){
        if(special.y==-1){
            ans+=negp.size();
        }
        else{
            ans+=posn.size();
        }
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
//#define sqr(x) ((x)*(x))
#define EPS 1e-7
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define Line pair<pii,pii>
typedef long long LL;
#define hash Hash
int main(){
    int n,l,w;
    scanf("%d %d %d",&n,&l,&w);
    vector<int> posn,posp,negn,negp;
    pii special=mp(-1e9,0);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a>=0){
            if(b>=0)
            posp.pb(a);
            if(b<0)
            posn.pb(a);
        }
        else if(a>-l){
            special=mp(a,b);
        }
        else{
            if(b>=0)
            negp.pb(-a-l);
            if(b<0)
            negn.pb(-a-l);
        }
    }
    sort(posn.begin(),posn.end());
    sort(negp.begin(),negp.end());
    LL ans=(LL)posn.size()*negp.size();
   // printf("%lld\n",ans);
    if(w!=1){
        for(auto it:posp){
            int need=it/(w-1)*2-l+it;
           // printf("%d\n",need);
            ans+=posn.end()-upper_bound(posn.begin(),posn.end(),need);
        }
        for(auto it:negn){
            int need=it/(w-1)*2-l+it;
            ans+=negp.end()-upper_bound(negp.begin(),negp.end(),need);
        }
    }
    if(special.y!=0){
        if(special.y==-1){
            ans+=negp.size();
        }
        else{
            ans+=posn.size();
        }
    }
    printf("%lld\n",ans);
}


#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<deque>
#include<cmath>
#include<set>
#include<cstring>
#include<string.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
//----------------
#define int long long
//----------------
inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
#define sdf(x) x=read()
#define For(i, a, b) for (int i = (a); i <= (b); i++)
#define FFor(i, a, b) for (int i = (a); i >= (b); i--)
#define me(a, b) memset(a, b, sizeof(a))
#define mid ((l + ((r - l)/2)))
#define Edge struct edge{int to, nx, w;}e[N << 1];int fi[N];int ce = 1;
#define star_link inline void add(int u, int v, int w){e[++ce] = (edge){v, fi[u], w};fi[u] = ce;}
#define Go(u) for (int i = fi[u]; i; i = e[i].nx)
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define bg1(x) cout<<(#x)<<":"<<(x)<<" "<<endl
#define bg2(x,y) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<endl
#define bg3(x,y,z) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<endl
#define bg4(x,y,z,w) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<endl
#define bg5(x,y,z,w,k) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<(#k)<<":"<<(k)<<" "<<endl
int die = 0;
#define Die die++;if(die>100000){cout<<"dead!!!";exit(0);}
#define Left Lson[p]?Lson[p]:Lson[p]=++tot
#define Right Rson[p]?Rson[p]:Rson[p]=++tot
#define mk make_pair
#define pb push_back
const double eps = 1e-9;
// srand((unsigned)time(NULL));
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int n, len, mx;
int p1[N], p2[N];
int t1 = 0, t2 = 0;
int ans = 0;

void sol1() {
    sort(p1 + 1, p1 + 1 + t1), sort(p2 + 1, p2 + 1 + t2);
    // For(i,1,t1)bg2(i,p1[i]);
    // For(i,1,t2)bg2(i,p2[i]);
    int j = 1;
    For(i, 1, t1) {
        while (j <= t2 && p1[i] > p2[j])j++;
        if (j > t2)break;
        while (j <= t2 && abs(p1[i] + p2[j]+len)>= abs(p2[j] - p1[i]+len)*mx ) {
            j++;
        }
        if (j > t2)break;
        // bg2(i,j);
        ans += t2 - j + 1;

    }
    cout << ans;

}

void rd() {
    sdf(n), sdf(len), sdf(mx);
    For(i, 1, n) {
        int x, v;
        sdf(x), sdf(v);
        if (v == 1)p1[++t1] = x;
        else p2[++t2] = x;
    }
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    rd();
    sol1();

}


#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<deque>
#include<cmath>
#include<set>
#include<cstring>
#include<string.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
//----------------
#define int long long
//----------------
inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
#define sdf(x) x=read()
#define For(i, a, b) for (int i = (a); i <= (b); i++)
#define FFor(i, a, b) for (int i = (a); i >= (b); i--)
#define me(a, b) memset(a, b, sizeof(a))
#define mid ((l + ((r - l)/2)))
#define Edge struct edge{int to, nx, w;}e[N << 1];int fi[N];int ce = 1;
#define star_link inline void add(int u, int v, int w){e[++ce] = (edge){v, fi[u], w};fi[u] = ce;}
#define Go(u) for (int i = fi[u]; i; i = e[i].nx)
#define random(a, b) ((a) + rand() % ((b) - (a) + 1))
#define bg1(x) cout<<(#x)<<":"<<(x)<<" "<<endl
#define bg2(x,y) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<endl
#define bg3(x,y,z) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<endl
#define bg4(x,y,z,w) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<endl
#define bg5(x,y,z,w,k) cout<<(#x)<<":"<<(x)<<" "<<(#y)<<":"<<(y)<<" "<<(#z)<<":"<<(z)<<" "<<(#w)<<":"<<(w)<<" "<<(#k)<<":"<<(k)<<" "<<endl
int die = 0;
#define Die die++;if(die>100000){cout<<"dead!!!";exit(0);}
#define Left Lson[p]?Lson[p]:Lson[p]=++tot
#define Right Rson[p]?Rson[p]:Rson[p]=++tot
#define mk make_pair
#define pb push_back
const double eps = 1e-9;
// srand((unsigned)time(NULL));
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int n, len, mx;
int p1[N], p2[N];
int t1 = 0, t2 = 0;
int ans = 0;

void sol1() {
    sort(p1 + 1, p1 + 1 + t1), sort(p2 + 1, p2 + 1 + t2);
    // For(i,1,t1)bg2(i,p1[i]);
    // For(i,1,t2)bg2(i,p2[i]);
    int j = 1;
    For(i, 1, t1) {
        while (j <= t2 && p1[i] > p2[j])j++;
        if (j > t2)break;
        while (j <= t2 && abs(p1[i] + p2[j]+len)>= abs(p1[i] - p2[j]+len)*mx ) {
            j++;
        }
        if (j > t2)break;
        // bg2(i,j);
        ans += t2 - j + 1;

    }
    cout << ans;

}

void rd() {
    sdf(n), sdf(len), sdf(mx);
    For(i, 1, n) {
        int x, v;
        sdf(x), sdf(v);
        if (v == 1)p1[++t1] = x;
        else p2[++t2] = x;
    }
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    rd();
    sol1();

}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <bitset>
#include <ctime>

using namespace std;

#define pau system("pause")
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define clr(a, x) memset(a, x, sizeof(a))

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
tree<pli, null_type, greater<pli>, rb_tree_tag, tree_order_statistics_node_update> T;
*/

int n, l, w;
int x[100015], v[100015], cnt_p;
double p[100015];
int main() {
    scanf("%d%d%d", &n, &l, &w);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &x[i], &v[i]);
        if (v[i] < 0) p[++cnt_p] = x[i];
    }
    sort(p + 1, p + cnt_p + 1);
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (v[i] > 0) {
            if (x[i] + l <= 0) {
                ans += cnt_p + 1 - (upper_bound(p + 1, p + cnt_p + 1, (double)(w - 1) * x[i] / (w + 1) - l) - p);
            } else if (x[i] >= 0) {
                if (1 == w) continue;
                ans += cnt_p + 1 - (upper_bound(p + 1, p + cnt_p + 1, (double)(w + 1) * x[i] / (w - 1) - l) - p);
            } else {
                ans += cnt_p + 1 - (upper_bound(p + 1, p + cnt_p + 1, (double)x[i]) - p);
            }
        }
    }
    return !printf("%lld\n", ans);
    return 0;
}


#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <bitset>
#include <ctime>

using namespace std;

#define pau system("pause")
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define clr(a, x) memset(a, x, sizeof(a))

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
tree<pli, null_type, greater<pli>, rb_tree_tag, tree_order_statistics_node_update> T;
*/

int n, l, w;
int x[100015], v[100015], cnt_p;
double p[100015];
int main() {
    scanf("%d%d%d", &n, &l, &w);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &x[i], &v[i]);
        if (v[i] < 0) p[++cnt_p] = x[i];
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (v[i] > 0) {
            if (x[i] + l <= 0) {
                ans += cnt_p + 1 - (upper_bound(p + 1, p + cnt_p + 1, (double)(w - 1) * x[i] / (w + 1) - l) - p);
            } else if (x[i] >= 0) {
                if (1 == w) continue;
                ans += cnt_p + 1 - (upper_bound(p + 1, p + cnt_p + 1, (double)(w + 1) * x[i] / (w - 1) - l) - p);
            } else {
                ans += cnt_p + 1 - (upper_bound(p + 1, p + cnt_p + 1, (double)x[i]) - p);
            }
        }
    }
    return !printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define M 1000000007

#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))

typedef long long ll;
typedef long double ld;

vector<ll> vec1, vec2;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, l, w, x, v;
    cin>>n>>l>>w;
    for(int i=0; i<n; i++)
    {
    	cin>>x>>v;
    	if(v==1)
    	{
    		vec1.pb(x);
    	}
    	else
    	{
    		vec2.pb(x+l);
    	}
    }
    if(vec1.size()==0 || vec2.size()==0)
    {
    	cout<<0;
    	return 0;
    }
    sort(vec2.begin(), vec2.end());
    ll ans=0;
    for(ll i=0; i<vec1.size(); i++)
    {
    	ll st=0, en=vec2.size()-1, mid=-1, f1=w-1, f2=w+1;
    	x=vec1[i];
    	if(w==1 && x>=0)
    	{
    		continue;
    	}
    	while(st<=en)
    	{
    		mid=(st+en)/2;
    		if(mid>=0 && mid<vec2.size() && (f2*vec2[mid])>(f1*x) && (f1*vec2[mid])>(f2*x))
    		{
    			en=mid-1;
    		}
    		else
    		{
    			mid++;
    			st=mid+1;
    		}
    	}
    	if(mid>=0 && mid<vec2.size() && (f2*vec2[mid])>(f1*x) && (f1*vec2[mid])>(f2*x))
    	{
    		ans+=vec2.size()-mid;
    	}
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define M 1000000007

#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))

typedef long long ll;
typedef long double ld;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, l, w, x, v;
    cin>>n>>l>>w;
    vector<ll> vec1, vec2;
    for(int i=0; i<n; i++)
    {
    	cin>>x>>v;
    	if(v==1)
    	{
    		vec1.pb(x);
    	}
    	else
    	{
    		vec2.pb(x+l);
    	}
    }
    sort(vec2.begin(), vec2.end());
    ll ans=0;
    for(int i=0; i<vec1.size(); i++)
    {
    	ll st=0, en=vec2.size()-1, mid=-1, f1=w-1, f2=w+1;
    	x=vec1[i];
    	while(st<=en)
    	{
    		mid=(st+en)/2;
    		if((f2*vec2[mid]>f1*x)&&(f1*vec2[mid]>f2*x))
    		{
    			en=mid-1;
    		}
    		else
    		{
    			mid++;
    			st=mid+1;
    		}
    	}
    	if(mid>=0 && mid<vec2.size() && (f2*vec2[mid]>f1*x) && (f1*vec2[mid]>f2*x))
    	{
    		ans+=vec2.size()-mid;
    	}
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define M 1000000007

#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))

typedef long long ll;
typedef long double ld;

vector<ll> vec1, vec2;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, l, w, x, v;
    cin>>n>>l>>w;
    for(int i=0; i<n; i++)
    {
    	cin>>x>>v;
    	if(v==1)
    	{
    		vec1.pb(x);
    	}
    	else
    	{
    		vec2.pb(x+l);
    	}
    }
    if(vec1.size()==0 || vec2.size()==0)
    {
    	cout<<0;
    	return 0;
    }
    sort(vec2.begin(), vec2.end());
    ll ans=0;
    for(ll i=0; i<vec1.size(); i++)
    {
    	ll st=0, en=vec2.size()-1, mid=-1, f1=w-1, f2=w+1;
    	x=vec1[i];
    	if(w==1 && x>=0)
    	{
    		continue;
    	}
    	while(st<=en)
    	{
    		mid=(st+en)/2;
    		if(mid>=0 && mid<vec2.size() && x<vec2[mid] && (f2*vec2[mid])>(f1*x) && (f1*vec2[mid])>(f2*x))
    		{
    			en=mid-1;
    		}
    		else
    		{
    			mid++;
    			st=mid+1;
    		}
    	}
    	if(mid>=0 && mid<vec2.size() && x<vec2[mid] && (f2*vec2[mid])>(f1*x) && (f1*vec2[mid])>(f2*x))
    	{
    		ans+=vec2.size()-mid;
    	}
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define M 1000000007

#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))

typedef long long ll;
typedef long double ld;

vector<ll> vec1, vec2;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, l, w, x, v;
    cin>>n>>l>>w;
    for(int i=0; i<n; i++)
    {
    	cin>>x>>v;
    	if(v==1)
    	{
    		vec1.pb(x);
    	}
    	else
    	{
    		vec2.pb(x+l);
    	}
    }
    if(vec1.size()==0 || vec2.size()==0)
    {
    	cout<<0;
    	return 0;
    }
    sort(vec2.begin(), vec2.end());
    ll ans=0;
    for(ll i=0; i<vec1.size(); i++)
    {
    	ll st=0, en=vec2.size()-1, mid=-1, f1=w-1, f2=w+1;
    	x=vec1[i];
    	while(st<=en)
    	{
    		mid=(st+en)/2;
    		if(mid>=0 && mid<vec2.size() && (f2*vec2[mid])>(f1*x) && (f1*vec2[mid])>(f2*x))
    		{
    			en=mid-1;
    		}
    		else
    		{
    			mid++;
    			st=mid+1;
    		}
    	}
    	if(mid>=0 && mid<vec2.size())
    	{
    		ans+=vec2.size()-mid;
    	}
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define M 1000000007

#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))

typedef long long ll;
typedef long double ld;

vector<ll> vec1, vec2;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, l, w, x, v;
    cin>>n>>l>>w;
    for(int i=0; i<n; i++)
    {
    	cin>>x>>v;
    	if(v==1)
    	{
    		vec1.pb(x);
    	}
    	else
    	{
    		vec2.pb(x+l);
    	}
    }
    if(vec1.size()==0 || vec2.size()==0)
    {
    	cout<<0;
    	return 0;
    }
    sort(vec2.begin(), vec2.end());
    ll ans=0;
    for(ll i=0; i<vec1.size(); i++)
    {
    	ll st=0, en=vec2.size()-1, mid=-1, f1=w-1, f2=w+1;
    	x=vec1[i];
    	if(w==1 && x>=0)
    	{
    		continue;
    	}
    	while(st<=en)
    	{
    		mid=(st+en)/2;
    		if(mid>=0 && mid<vec2.size() && x<vec2[mid] && (f2*vec2[mid])>(f1*x) && (f1*vec2[mid])>(f2*x))
    		{
    			en=mid-1;
    		}
    		else
    		{
    			st=mid+1;
    			mid++;
    		}
    	}
    	if(mid>=0 && mid<vec2.size() && x<vec2[mid] && (f2*vec2[mid])>(f1*x) && (f1*vec2[mid])>(f2*x))
    	{
    		ans+=vec2.size()-mid;
    	}
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
#define LL long long
int x1[maxn], x2[maxn], s1, s2, s;
LL ans = 0;
int main() {
	int n, l, w, x, y;
	scanf("%d%d%d", &n, &l, &w);
	for (int i = 0; i<n; i++) {
		scanf("%d%d", &x, &y);
		if (y == 1)x1[s1++] = x;
		else x2[s2++] = x;
	}
	sort(x1, x1 + s1); sort(x2, x2 + s2);
	for (int i = 0; i<s1; i++) {
		while (s<s2 && (x2[s]<x1[i] || (fabs((x2[s] + x1[i] + l) / 2.0) >= 0.5*w*(x2[s] - x1[i] + l))))
			s++;
		ans += s2 - s;
	}
	printf("%I64d", ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100010;
int n, n1, n2, l, w, ri;
int a1[N], a2[N];
ll ans;

int main()
{
	scanf("%d%d%d", &n, &l, &w);
	n1 = n2 = 0;
	for (int i = 0; i < n; ++ i){
		int x, y;
		scanf("%d%d", &x, &y);
		if (y == 1){
			a1[n1 ++] = x;
		}
		else{
			a2[n2 ++] = x;
		}
	}
	sort(a1, a1+n1);
	sort(a2, a2+n2);
	ans = 0; ri = 0;
	for (int i = 0; i < n1; ++ i){
		while (ri < n2){
			ll x = a1[i]+a2[ri]+l;
			ll t = a2[ri]-a1[i]+l;
			// cout << i << " " << ri << " " << x << " " << t << endl;
			if (t < 0 || x <= -t*w || x >= t*w){
				++ ri;
				continue;
			}
			else{
				break;
			}
		}
		ans += n2-ri;
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int n;
long long l,w;

long long tr[100005],tl[100005];
int cntr,cntl;

bool check(long long x1,long long x2)
{
    double xx=1.0*(x1+x2)/2.0;
    double yy=1.0*(x2-x1)/2.0;

    if(1.0*yy*w > (-xx)  && 1.0*yy*w > (xx))
    {
        return true;
    }
    else
        return false;
}

int bin(long long x)
{
    int l=0,r=cntl-1;
    while(l<r)
    {
        int mid=(l+r)/2;
        if(check(x,tl[mid]))
        {
            r=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    if(check(x,tl[l])==false)
    {
        l++;
    }
    return min(l,cntl);
}

int main() {

    while(~scanf("%d%lld%lld",&n,&l,&w))
    {
        cntr=cntl=0;

        for(int i=0;i<n;i++)
        {
            long long id,f;
            scanf("%lld%lld",&id,&f);
            if(f==1)
            {
                tr[cntr]=id;
                cntr++;
            }
            else
            {
                id+=l;
                tl[cntl]=id;
                cntl++;
            }
        }

        sort(tr,tr+cntr);
        sort(tl,tl+cntl);

        long long ans=0;

        //cout<<tr[0]<<" "<<tl[0]<<endl;
        //cout<<check(tr[0],tl[0])<<endl;
        for(int i=0;i<cntr;i++)
        {
            //cout<<bin(tr[i])<<endl;
            ans+=(cntl-bin(tr[i]));
            //cout<<ans<<endl;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int n;
long long l,w;

long long tr[100005],tl[100005];
int cntr,cntl;

bool check(long long x1,long long x2)
{
    double xx=1.0*(x1+x2)/2.0;
    double yy=1.0*(x2-x1)/2.0;

    if(1.0*yy*w > (-xx)  && 1.0*yy*w > (xx))
    {
        return true;
    }
    else
        return false;
}

int bin(long long x)
{
    int l=0,r=cntl-1;
    while(l<r)
    {
        int mid=(l+r)/2;
        if(check(x,tl[mid]))
        {
            r=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    if(check(x,tl[l])==false)
    {
        l++;
    }
    return l;
}

int main() {

    while(~scanf("%d%lld%lld",&n,&l,&w))
    {
        cntr=cntl=0;

        for(int i=0;i<n;i++)
        {
            long long id,f;
            scanf("%lld%lld",&id,&f);
            if(f==1)
            {
                tr[cntr]=id;
                cntr++;
            }
            else
            {
                id+=l;
                tl[cntl]=id;
                cntl++;
            }
        }

        sort(tr,tr+cntr);
        sort(tl,tl+cntl);

        long long ans=0;

        //cout<<tr[0]<<" "<<tl[0]<<endl;
        //cout<<check(tr[0],tl[0])<<endl;
        for(int i=0;i<cntr;i++)
        {
            //cout<<bin(tr[i])<<endl;
            ans+=(cntl-bin(tr[i]));
            //cout<<ans<<endl;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int N = 1e5 + 10;
int n, l, wmax;
ll x[N], v[N];
ll ans = 0;
ld eps = 1e-9;
ld half = 0;

bool canmeet(int u, int v){
    if(u > v) return false;
    ld m = (u + l + v) / (ld) 2.0;
    if(-half <= m && m <= half) return true;
    if(m < -half){
        ld tm = 0.5 + (v - m);
        ld di = -(m + half);
        return di / tm <= wmax - eps || (abs(m)) / (m - u - l + 1) <= wmax - eps;;
    }
    else{

        ld tm = 0.5 + (v - m);
        ld di = m - half;
        return di / tm <= wmax - eps || (m) / (tm + 0.5) <= wmax - eps;
    }
    return true;
}

int main(){

    scanf("%d%d%d", &n, &l, &wmax);
    for(int i = 1; i <= n; i++){
        scanf("%lld%lld", &x[i], &v[i]);
    }

    half = (ld) l / (ld) 2.0;

    vector<ll> pos, neg;
    for(int i = 1; i <= n; i++){
        if(v[i] == 1) pos.pb(x[i]);
        else neg.pb(x[i]);
    }
    neg.pb(-1e9);

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    int L = 0, R = 0;

    for(int i = 0; i < pos.size(); i++){
        int curp = pos[i];
        // do R
        if(canmeet(curp, neg[R])){
            while(R + 1 < neg.size() && canmeet(curp, neg[R + 1])) R++;
            while(L + 1 < R && L + 1 < neg.size() && !canmeet(curp, neg[L + 1])) L++;
        }
        else{
            L = R;
            while(L + 1 < neg.size() && !canmeet(curp, neg[L + 1])) L++;
            R = L + 1;
            while(R + 1 < neg.size() && canmeet(curp, neg[R + 1])) R++;
        }

        if(R < neg.size()){

            ans += R - L;
        }
    }

    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int N = 1e5 + 10;
int n, l, wmax;
ll x[N], v[N];
ll ans = 0;
ld eps = 1e-9;
ld half = 0;

bool canmeet(int u, int v){
    if(u > v) return false;
    ld m = (u + l + v) / (ld) 2.0;
    if(-half <= m && m <= half) return true;
    if(m < -half){
        ld tm = 0.5 + (v - m);
        ld di = -(m + half);
        return di / (tm - eps) <= wmax || (abs(m)) / (m - u - l + 1 - eps) <= wmax;;
    }
    else{

        ld tm = 0.5 + (v - m);
        ld di = m - half;
        return di / (tm - eps) <= wmax - eps || (m) / (tm + 0.5 - eps) <= wmax;
    }
    return true;
}

int main(){

    scanf("%d%d%d", &n, &l, &wmax);
    for(int i = 1; i <= n; i++){
        scanf("%lld%lld", &x[i], &v[i]);
    }

    half = (ld) l / (ld) 2.0;

    vector<ll> pos, neg;
    for(int i = 1; i <= n; i++){
        if(v[i] == 1) pos.pb(x[i]);
        else neg.pb(x[i]);
    }
    neg.pb(-1e9);

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    int L = 0, R = 0;

    for(int i = 0; i < pos.size(); i++){
        int curp = pos[i];
        // do R
        if(canmeet(curp, neg[R])){
            while(R + 1 < neg.size() && canmeet(curp, neg[R + 1])) R++;
            while(L + 1 < R && L + 1 < neg.size() && !canmeet(curp, neg[L + 1])) L++;
        }
        else{
            L = R;
            while(L + 1 < neg.size() && !canmeet(curp, neg[L + 1])) L++;
            R = L + 1;
            while(R + 1 < neg.size() && canmeet(curp, neg[R + 1])) R++;
        }

        if(R < neg.size()){

            ans += R - L;
        }
    }

    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

int main(){

	int n, l, wmax;
	scanf("%d%d%d", &n, &l, &wmax);
	vector<int> plus, minus;
	for(int i = 1; i <= n; i++){
		int x, v;
		scanf("%d%d", &x, &v);
		if(v == 1) plus.pb(x);
		else minus.pb(x);
	}

	sort(plus.begin(), plus.end());
	sort(minus.begin(), minus.end());

	ll ans = 0;
	vector<int>::iterator it = minus.begin();
	for(int x : plus){
		while(it != minus.end() && (*it < x || wmax * 1ll * (*it + l - x) <= abs(x + *it + l)))
			it++;
		ans += minus.end() - it;
	}

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

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int N = 1e5 + 10;
int n, l, wmax;
ll x[N], v[N];
ll ans = 0;
ld eps = 1e-9;
ld half = 0;

bool canmeet(int u, int v){
    if(u > v) return false;
    ld m = (u + l + v) / (ld) 2.0;
    if(-half <= m && m <= half) return true;
    if(m < -half){
        ld tm = 0.5 + (m - u - l);
        ld di = -(m + half);
        return di / tm <= wmax;
    }
    else{
        ld tm = 0.5 + (m - u - l);
        ld di = m - half;
        return di / tm <= wmax;
    }
    return true;
}

int main(){

    scanf("%d%d%d", &n, &l, &wmax);
    for(int i = 1; i <= n; i++){
        scanf("%lld%lld", &x[i], &v[i]);
    }

    half = (ld) l / (ld) 2.0;

    vector<ll> pos, neg;
    for(int i = 1; i <= n; i++){
        if(v[i] == 1) pos.pb(x[i]);
        else neg.pb(x[i]);
    }
    neg.pb(-1e9);

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    int L = 0, R = 0;

    for(int i = 0; i < pos.size(); i++){
        int curp = pos[i];
        // do R
        if(canmeet(curp, neg[R])){
            while(R + 1 < neg.size() && canmeet(curp, neg[R + 1])) R++;
            while(L + 1 < R && L + 1 < neg.size() && !canmeet(curp, neg[L + 1])) L++;
        }
        else{
            L = R;
            while(L + 1 < neg.size() && !canmeet(curp, neg[L + 1])) L++;
            R = L + 1;
            while(R + 1 < neg.size() && canmeet(curp, neg[R + 1])) R++;
        }
        // cout << i << " " << L << " " << R << endl;

        if(R < neg.size()){

            ans += R - L;
        }
    }

    cout << ans << endl;
    return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=1E5+77;

int N,L,WM,X[maxn],Y[maxn],cx,cy;

bool check(int x,int y){
	int p=x+L+y,t=y+L-x;
	if(p<0) p=-p;
	return WM*(long long)t>p;
}

int main(){
	scanf("%d%d%d",&N,&L,&WM);
	for(int i=0;i<N;++i){
		int x,v;scanf("%d%d",&x,&v);
		if(v>0) X[cx++]=x;
		else Y[cy++]=x;
	}
	sort(X,X+cx);sort(Y,Y+cy);
	long long ans=0;
	int p=cy;
	for(int i=cx-1;i>=0;--i){
		while(p && check(X[i],Y[p-1])) --p;
		ans+=cy-p;
	}
	cout<<ans<<endl;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=1E5+77;

int N,L,WM,X[maxn],Y[maxn],cx,cy;

bool check(int x,int y){
	int p=x+L+y,t=y+L-x;
	if(p<0) p=-p;
	return WM*t>p;
}

int main(){
	scanf("%d%d%d",&N,&L,&WM);
	for(int i=0;i<N;++i){
		int x,v;scanf("%d%d",&x,&v);
		if(v>0) X[cx++]=x;
		else Y[cy++]=x;
	}
	sort(X,X+cx);sort(Y,Y+cy);
	long long ans=0;
	int p=cy;
	for(int i=cx-1;i>=0;--i){
		while(p && check(X[i],Y[p-1])) --p;
		ans+=cy-p;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
const ll N=1e5+100;
ll n,l,w,x,ve,z,l1,l2,r3,r4,ans=0;
vector <ll> v;
vector < pair <ll,ll> > s;

bool cmp1(ll y,ll x)
{
	y*=(w-1);
	x*=(w+1);
	if(y<x)
		return 1;
	else
		return 0;
}
bool cmp2(ll y,ll x)
{
	//cout << "Start : " << y << ' ' << x << endl;
	y*=(w+1);
        x*=(w-1);
	//cout << "End : " << y << ' ' << x << endl;
        if(y<x)
                return 1;
        else
                return 0;
}
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin >> n >> l >> w;
	for(int i=1; i<=n; i++)
	{
		cin >> x >> ve;
		s.push_back({x,ve});
	}
	sort(s.begin(),s.end());
	for(auto y:s)
	{
		if(y.second==1)
		{
			v.push_back(y.first);
			continue;
		}
		//cout << y.first << ' ' << y.second << endl;
		x=y.first;
		l1=lower_bound(v.begin(),v.end(),x+l,cmp1)-v.begin();
		l2=lower_bound(v.begin(),v.end(),-x-l)-v.begin();
		//cout << l1 << ' ' << l2 << endl;
		l1=min(l1,l2);
		//r3=lower_bound(v.begin(),v.end(),x)-v.begin()-l2;
		r3=lower_bound(v.begin(),v.end(),x+l,cmp2)-v.begin()-l2;
		//cout << r3 << endl;
		ans+=l1+r3;
		//cout << l1 << ' ' << r3 << endl;
	}
	cout << ans;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define per(i, a, b) for(int i = a - 1; i >= b; --i)
#define vi vector<int>
#define vvi vector<vector<int> >
#define pii pair<int, int>
#define piii pair<int,pair<int, int> >
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define SPD ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main(){
    int n,l,w;cin>>n>>l>>w;
    vector<int>a;
    vector<double>b;
    if(w==1){
        ll rs=0;
        ll rs2=0;
        rep(i,0,n){
            int c,v;cin>>c>>v;
            if(v==1)rs+=c<0;
            else rs2+=((c+l)>0);
        }
        cout<<rs*rs2;
        return 0;
    }
    rep(i,0,n){
        int c,v;cin>>c>>v;
        if(v==-1)a.pb(c+l);
        else {
            if(c<=0)b.pb(1.0*c/(w+1)*w);
            else b.pb(1.0*c/(w-1)*w);
        }
    }
    ll rs=0;
    sort(b.begin(),b.end());
    rep(i,0,a.size()){
        double tmp;
        if(a[i]<=0)tmp=1.0*a[i]/(w-1)*w;
        else tmp=1.0*a[i]/(w+1)*w;
        rs+=lb(b.begin(),b.end(),tmp)-b.begin();
    }
    cout<<rs;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define per(i, a, b) for(int i = a - 1; i >= b; --i)
#define vi vector<int>
#define vvi vector<vector<int> >
#define pii pair<int, int>
#define piii pair<int,pair<int, int> >
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define SPD ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main(){
    int n,l,w;cin>>n>>l>>w;
    vector<int>a;
    vector<double>b;
    if(w==1){
        ll rs=0;
        ll rs2=0;
        rep(i,0,n){
            int c,v;cin>>c>>v;
            if(v==1)rs+=c<0;
            else rs2+=((c+l)>0);
        }
        cout<<rs*rs2;
        return 0;
    }
    rep(i,0,n){
        int c,v;cin>>c>>v;
        if(v==-1)a.pb(c+l);
        else {
            if(c<=0)b.pb(1.0*c/(w+1)*w);
            else b.pb(1.0*c/(w-1)*w);
        }
    }
    ll rs=0;
    //rep(i,0,b.size())cout<<b[i]<<' ';cout<<'\n';
    rep(i,0,a.size()){
        double tmp;
        if(a[i]<=0)tmp=1.0*a[i]/(w-1)*w;
        else tmp=1.0*a[i]/(w+1)*w;
        //cout << tmp << ' ';
        rs+=lb(b.begin(),b.end(),tmp)-b.begin();
        //cout << a[i]-l << ' ' << rs << '\n';
    }
    cout<<rs;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define per(i, a, b) for(int i = a - 1; i >= b; --i)
#define vi vector<int>
#define vvi vector<vector<int> >
#define pii pair<int, int>
#define piii pair<int,pair<int, int> >
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define SPD ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

ll M=1e9+7;
ll _pow(ll a, ll x){
    ll rs=1;
    a=a%M;
    while(x){
        if(x&1)rs=(rs*a)%M;
        x>>=1;
        a=(a*a)%M;
    }
    return rs;
}
int main(){
    SPD;
    ll x,k;cin>>x>>k;
    if(x==0){
        cout<<0;
        return 0;
    }
    x=x%M;
    cout << ((x*_pow(1LL*2,k+1))%M-_pow(1LL*2,k)+1LL*1+2*M)%M;
    return 0;
}