// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>

using namespace std;

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

const int N = (int) 1e5 + 5, mod = 0;

int a[N], b[N], sz, lis[N], plvl[N], mark[N];
vector<int> level[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	rep(i, n)
		cin >> a[i];
	int m;
	cin >> m;
	rep(i, m)
		cin >> b[i];
	sort(b, b + m);
	rep(i, n) {
		if (a[i] > 0) {
			int pos = lower_bound(lis, lis + sz, a[i]) - lis;
			lis[pos] = a[i];
			level[pos].push_back(i);
			plvl[i] = pos;
			sz = max(sz, pos + 1);
		} else {
			int p = sz;
			for (int i = m - 1; i >= 0; --i) {
				int x = b[i];
				while (p > 0 && lis[p - 1] >= x)
					p--;
				lis[p] = x;
				sz = max(sz, p + 1);
			}
		}
	}
	int curl = sz - 1, last = (int) 2e9;
	for (int i = n - 1; i >= 0; --i) if (curl >= 0) {
		if (a[i] > 0) {
			if (plvl[i] == curl) {
				curl--;
				last = a[i];
			}
		} else {
			int pos = lower_bound(level[curl].begin(), level[curl].end(), i) - level[curl].begin() - 1;
			if (pos < 0 || a[level[curl][pos]] >= last) {
				int p = lower_bound(b, b + m, last) - b - 1;
				mark[p] = 1;
				a[i] = b[p];
				last = a[i];
				curl--;
			}
		}
	}
	int pt = 0;
	rep(i, n) {
		if (a[i] < 0) {
			while (mark[pt])
				pt++;
			a[i] = b[pt++];
		}
		cout << a[i] << ' ';
	}
}


// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>

using namespace std;

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

const int N = (int) 1e5 + 5, mod = 0;

int a[N], b[N], sz, lis[N], plvl[N], mark[N];
vector<int> level[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	rep(i, n)
		cin >> a[i];
	int m;
	cin >> m;
	rep(i, m)
		cin >> b[i];
	sort(b, b + m);
	rep(i, n) {
		if (a[i] > 0) {
			int pos = lower_bound(lis, lis + sz, a[i]) - lis;
			lis[pos] = a[i];
			level[pos].push_back(a[i]);
			plvl[i] = pos;
			sz = max(sz, pos + 1);
		} else {
			int p = sz;
			for (int i = m - 1; i >= 0; --i) {
				int x = b[i];
				while (p > 0 && lis[p - 1] >= x)
					p--;
				lis[p] = x;
				sz = max(sz, p + 1);
			}
		}
	}
	int curl = sz - 1, last = (int) 2e9;
	for (int i = n - 1; i >= 0; --i) if (curl >= 0) {
		if (a[i] > 0) {
			if (plvl[i] == curl) {
				curl--;
				last = a[i];
			}
		} else {
			int pos = lower_bound(level[curl].begin(), level[curl].end(), i) - level[curl].begin() - 1;
			if (pos < 0) {
				int p = lower_bound(b, b + m, last) - b - 1;
				mark[p] = 1;
				a[i] = b[p];
				last = a[i];
				curl--;
			}
		}
	}
	int pt = 0;
	rep(i, n) {
		if (a[i] < 0) {
			while (mark[pt])
				pt++;
			a[i] = b[pt++];
		}
		cout << a[i] << ' ';
	}
}


//In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
pair<int,pair<int,int> > lis[N];
int par[N];
int arr[N],gap[N],sz,ans[N];
int last[N];
int mark[N],n,k,m;
void call(int x,int p) {
	if(par[x] != -1) call(par[x],last[p]);
	if(x & 1) ans[p] = gap[x >> 1];
	else ans[p] = arr[x >> 1];
	return;
}
int do_lis(int rs = -1) {
	sz = 0;
	for(int i = 0; i < N; ++i) lis[i].first = 1e9 + 1;
	for(int i = 0; i < n; ++i) {
		if(arr[i] == -1) {
			int p = sz - 1;
			for(int j = 0; j < m; ++j) {
				int x = gap[j];
				while(p >= 0 && lis[p].first > x) --p;
				if((p < 0 || lis[p].first < x) && lis[p + 1].first > x) {
					lis[p + 1] = {x,{i,j}},sz = max(sz,p+2);
					if(lis[p].second.second != N-1) par[j * 2 + 1] = 2 * (lis[p].second.second) + 1;
					else par[j * 2 + 1] = lis[p].second.first * 2;
				}
			}
		} else {
			int pl = lower_bound(lis,lis+sz,make_pair(arr[i],make_pair(-1,-1))) - lis;
			if(lis[pl].first > arr[i]) lis[pl] = {arr[i],{i,N-1}},sz = max(sz,pl+1);
			if(pl == 0) par[i * 2] = -1;
			else {
				if(lis[pl - 1].second.second != N-1) par[i * 2] = 2 * (lis[pl - 1].second.second) + 1;
				else par[i * 2] = lis[pl - 1].second.first * 2;
			}
		}
		if(rs == sz) {
			int p;
			if(lis[sz - 1].second.second != N-1) p = 2 * lis[sz - 1].second.second + 1;
			else p = 2 * lis[sz - 1].second.first * 2;
			call(p,lis[sz - 1].second.first);
//			for(int j = 0; j < sz; ++j) {
//				int id = lis[j].second.first;
//				ans[id] = lis[j].first;
//				mark[lis[j].second.second] = 1;
//			}
//			return 0;
		}
	}
	return sz;
}
int main() {
	memset(ans,-1,sizeof ans);
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) scanf("%d",&arr[i]),k += (arr[i] == -1),ans[i] = arr[i],last[i] = (arr[i] == -1 ? i : (i ? last[i-1] : -1));
	scanf("%d",&m);
	for(int i = 0; i < m; ++i) scanf("%d",&gap[i]);
	sort(gap,gap+m);
	reverse(gap,gap+m);
	int real_size = do_lis();
	do_lis(real_size);
	int p = 0;
	for(int j = 0; j < n;++j) {
		if(ans[j] == -1) {
			while(mark[p]) ++p;
			ans[j] = gap[p++];
		}
	}
	for(int i = 0; i < n; ++i) printf("%d ",ans[i]);
	return 0;
}


// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>

using namespace std;

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

const int N = (int) 1e5 + 5, mod = 0;

int a[N], b[N], sz, lis[N], plvl[N], mark[N];
vector<int> level[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	rep(i, n)
		cin >> a[i];
	int m;
	cin >> m;
	rep(i, m)
		cin >> b[i];
	sort(b, b + m);
	rep(i, n) {
		if (a[i] > 0) {
			int pos = lower_bound(lis, lis + sz, a[i]) - lis;
			lis[pos] = a[i];
			level[pos].push_back(a[i]);
			plvl[i] = pos;
			sz = max(sz, pos + 1);
		} else {
			int p = sz;
			for (int i = m - 1; i >= 0; --i) {
				int x = b[i];
				while (p > 0 && lis[p - 1] >= x)
					p--;
				lis[p] = x;
				sz = max(sz, p + 1);
			}
		}
	}
	int curl = sz - 1, last = (int) 2e9;
	for (int i = n - 1; i >= 0; --i) if (curl >= 0) {
		if (a[i] > 0) {
			curl -= (plvl[i] == curl);
			if (plvl[i] == curl)
				last = a[i];
		} else {
			int pos = lower_bound(level[curl].begin(), level[curl].end(), i) - level[curl].begin() - 1;
			if (pos < 0) {
				int p = lower_bound(b, b + m, last) - b - 1;
				mark[p] = 1;
				a[i] = b[p];
				last = a[i];
				curl--;
			}
		}
	}
	int pt = 0;
	rep(i, n) {
		if (a[i] < 0) {
			while (mark[pt])
				pt++;
			a[i] = b[pt++];
		}
		cout << a[i] << ' ';
	}
}


//In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
pair<int,pair<int,int> > lis[N];
int par[N];
int arr[N],gap[N],sz,ans[N];
int last[N];
int mark[N],n,k,m;
void call(int x,int p) {
	if(p == -1) return;
	if((par[x] & 1) == 0) last[p] = par[x] >> 1;
	if(par[x] != -1) call(par[x],last[p]);
	if(x & 1) ans[p] = gap[x >> 1],mark[x >> 1] = 1;
	else ans[p] = arr[x >> 1];
	return;
}
int do_lis(int rs = -1) {
	sz = 0;
	for(int i = 0; i < N; ++i) lis[i].first = 1e9 + 1;
	for(int i = 0; i < n; ++i) {
		if(arr[i] == -1) {
			int p = sz - 1;
			for(int j = 0; j < m; ++j) {
				int x = gap[j];
				while(p >= 0 && lis[p].first > x) --p;
				if((p < 0 || lis[p].first < x) && lis[p + 1].first > x) {
					lis[p + 1] = {x,{i,j}},sz = max(sz,p+2);
					if(p < 0) continue;
					if(lis[p].second.second != N-1) par[j * 2 + 1] = 2 * (lis[p].second.second) + 1;
					else par[j * 2 + 1] = lis[p].second.first * 2;
				}
			}
		} else {
			int pl = lower_bound(lis,lis+sz,make_pair(arr[i],make_pair(-1,-1))) - lis;
			if(lis[pl].first > arr[i]) lis[pl] = {arr[i],{i,N-1}},sz = max(sz,pl+1);
			if(pl == 0) par[i * 2] = -1;
			else {
				if(lis[pl - 1].second.second != N-1) par[i * 2] = 2 * (lis[pl - 1].second.second) + 1;
				else par[i * 2] = lis[pl - 1].second.first * 2;
			}
		}
		if(rs == sz) {
			int p;
			if(lis[sz - 1].second.second != N-1) p = 2 * lis[sz - 1].second.second + 1;
			else p = 2 * lis[sz - 1].second.first;
			call(p,lis[sz - 1].second.first);
			return 0;
//			for(int j = 0; j < sz; ++j) {
//				int id = lis[j].second.first;
//				ans[id] = lis[j].first;
//				mark[lis[j].second.second] = 1;
//			}
//			return 0;
		}
	}
	return sz;
}
int main() {
	memset(ans,-1,sizeof ans);
	memset(par,-1,sizeof par);
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) scanf("%d",&arr[i]),k += (arr[i] == -1),ans[i] = arr[i];
	last[0] = -1;
	for(int i = 1; i < n; ++i) {
		last[i] = (arr[i-1] == -1 ? i - 1 : last[i - 1]);
	}
	scanf("%d",&m);
	for(int i = 0; i < m; ++i) scanf("%d",&gap[i]);
	sort(gap,gap+m);
	reverse(gap,gap+m);
	int real_size = do_lis();
	do_lis(real_size);
	int p = 0;
	for(int j = 0; j < n;++j) {
		if(ans[j] == -1 || !ans[j]) {
			while(mark[p]) ++p;
			ans[j] = gap[p++];
		}
	}
	for(int i = 0; i < n; ++i) printf("%d ",ans[i]);
	return 0;
}


//In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
pair<int,pair<int,int> > lis[N];
int arr[N],gap[N],sz,ans[N];
int mark[N],n,k,m;
int do_lis(int rs = -1) {
	sz = 0;
	for(int i = 0; i < N; ++i) lis[i].first = 1e9 + 1;
	for(int i = 0; i < n; ++i) {
		if(arr[i] == -1) {
			int p = sz - 1;
			for(int j = 0; j < m; ++j) {
				int x = gap[j];
				while(p >= 0 && lis[p].first >= x) --p;
				if((p < 0 || lis[p].first < x) && lis[p + 1].first > x) lis[p + 1] = {x,{i,j}},sz = max(sz,p+2);
			}
		} else {
			int pl = lower_bound(lis,lis+sz,make_pair(arr[i],make_pair(-1,-1))) - lis;
			if(lis[pl].first > arr[i]) lis[pl] = {arr[i],{i,N-1}},sz = max(sz,pl+1);
		}
		if(rs == sz) {
			for(int j = 0; j < sz; ++j) {
				int id = lis[j].second.first;
				ans[id] = lis[j].first;
				mark[lis[j].second.second] = 1;
			}
			int p = 0;
			for(int j = 0; j < n;++j) {
				if(ans[j] == -1) {
					while(mark[p]) ++p;
					ans[j] = gap[p++];
				}
			}
			return 0;
		}
	}
	return sz;
}
int main() {
	memset(ans,-1,sizeof ans);
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) scanf("%d",&arr[i]),k += (arr[i] == -1),ans[i] = arr[i];
	scanf("%d",&m);
	for(int i = 0; i < m; ++i) scanf("%d",&gap[i]);
	sort(gap,gap+m);
	reverse(gap,gap+m);
	int real_size = do_lis();
	do_lis(real_size);
	for(int i = 0; i < n; ++i) printf("%d ",ans[i]);
	return 0;
}


// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>

using namespace std;

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

const int N = (int) 1e5 + 5, mod = 0;

int a[N], b[N], sz, lis[N], plvl[N], mark[N];
vector<int> level[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	rep(i, n)
		cin >> a[i];
	int m;
	cin >> m;
	rep(i, m)
		cin >> b[i];
	sort(b, b + m);
	rep(i, n) {
		if (a[i] > 0) {
			int pos = lower_bound(lis, lis + sz, a[i]) - lis;
			lis[pos] = a[i];
			level[pos].push_back(i);
			plvl[i] = pos;
			sz = max(sz, pos + 1);
		} else {
			int p = sz;
			for (int i = m - 1; i >= 0; --i) {
				int x = b[i];
				while (p > 0 && lis[p - 1] >= x)
					p--;
				lis[p] = x;
				sz = max(sz, p + 1);
			}
		}
	}
	int curl = sz - 1, last = (int) 2e9;
	for (int i = n - 1; i >= 0; --i) if (curl >= 0) {
		if (a[i] > 0) {
			if (plvl[i] == curl) {
				curl--;
				last = a[i];
			}
		} else {
			int pos = lower_bound(level[curl].begin(), level[curl].end(), i) - level[curl].begin() - 1;
			if (pos < 0) {
				int p = lower_bound(b, b + m, last) - b - 1;
				mark[p] = 1;
				a[i] = b[p];
				last = a[i];
				curl--;
			}
		}
	}
	int pt = 0;
	rep(i, n) {
		if (a[i] < 0) {
			while (mark[pt])
				pt++;
			a[i] = b[pt++];
		}
		cout << a[i] << ' ';
	}
}


//In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
pair<int,pair<int,int> > lis[N];
int par[N];
int arr[N],gap[N],sz,ans[N];
int last[N];
int mark[N],n,k,m;
void call(int x,int p) {
	if((par[x] & 1) == 0) last[p] = par[x] >> 1;
	if(par[x] != -1) call(par[x],last[p]);
	if(x & 1) ans[p] = gap[x >> 1],mark[x >> 1] = 1;
	else ans[p] = arr[x >> 1];
	return;
}
int do_lis(int rs = -1) {
	sz = 0;
	for(int i = 0; i < N; ++i) lis[i].first = 1e9 + 1;
	for(int i = 0; i < n; ++i) {
		if(arr[i] == -1) {
			int p = sz - 1;
			for(int j = 0; j < m; ++j) {
				int x = gap[j];
				while(p >= 0 && lis[p].first > x) --p;
				if((p < 0 || lis[p].first < x) && lis[p + 1].first > x) {
					lis[p + 1] = {x,{i,j}},sz = max(sz,p+2);
					if(p < 0) continue;
					if(lis[p].second.second != N-1) par[j * 2 + 1] = 2 * (lis[p].second.second) + 1;
					else par[j * 2 + 1] = lis[p].second.first * 2;
				}
			}
		} else {
			int pl = lower_bound(lis,lis+sz,make_pair(arr[i],make_pair(-1,-1))) - lis;
			if(lis[pl].first > arr[i]) lis[pl] = {arr[i],{i,N-1}},sz = max(sz,pl+1);
			if(pl == 0) par[i * 2] = -1;
			else {
				if(lis[pl - 1].second.second != N-1) par[i * 2] = 2 * (lis[pl - 1].second.second) + 1;
				else par[i * 2] = lis[pl - 1].second.first * 2;
			}
		}
		if(rs == sz) {
			int p;
			if(lis[sz - 1].second.second != N-1) p = 2 * lis[sz - 1].second.second + 1;
			else p = 2 * lis[sz - 1].second.first;
			call(p,lis[sz - 1].second.first);
			return 0;
//			for(int j = 0; j < sz; ++j) {
//				int id = lis[j].second.first;
//				ans[id] = lis[j].first;
//				mark[lis[j].second.second] = 1;
//			}
//			return 0;
		}
	}
	return sz;
}
int main() {
	memset(ans,-1,sizeof ans);
	memset(par,-1,sizeof par);
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) scanf("%d",&arr[i]),k += (arr[i] == -1),ans[i] = arr[i];
	for(int i = 1; i < n; ++i) {
		last[i] = (arr[i-1] == -1 ? i - 1 : last[i - 1]);
	}
	scanf("%d",&m);
	for(int i = 0; i < m; ++i) scanf("%d",&gap[i]);
	sort(gap,gap+m);
	reverse(gap,gap+m);
	int real_size = do_lis();
	do_lis(real_size);
	int p = 0;
	for(int j = 0; j < n;++j) {
		if(ans[j] == -1) {
			while(mark[p]) ++p;
			ans[j] = gap[p++];
		}
	}
	for(int i = 0; i < n; ++i) printf("%d ",ans[i]);
	return 0;
}


//In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
pair<int,pair<int,int> > lis[N];
int par[N];
int arr[N],gap[N],sz,ans[N];
int last[N];
int mrk[N];
int mark[N],n,k,m;
void call(int x,int p) {
	if(p == -1) return;
	mrk[p]++;
	if((par[x] & 1) == 0) last[p] = par[x] >> 1;
	if(par[x] != -1) call(par[x],last[p]);
	if(x & 1) ans[p] = gap[x >> 1],mark[x >> 1]++;
	else ans[p] = arr[x >> 1];
	return;
}
int do_lis(int rs = -1) {
	sz = 0;
	for(int i = 0; i < N; ++i) lis[i].first = 1e9 + 1;
	for(int i = 0; i < n; ++i) {
		if(arr[i] == -1) {
			int p = sz - 1;
			for(int j = 0; j < m; ++j) {
				int x = gap[j];
				while(p >= 0 && lis[p].first > x) --p;
				if((p < 0 || lis[p].first < x) && lis[p + 1].first > x) {
					lis[p + 1] = {x,{i,j}},sz = max(sz,p+2);
					if(p < 0) continue;
					if(lis[p].second.second != N-1) par[j * 2 + 1] = 2 * (lis[p].second.second) + 1;
					else par[j * 2 + 1] = lis[p].second.first * 2;
				}
			}
		} else {
			int pl = lower_bound(lis,lis+sz,make_pair(arr[i],make_pair(-1,-1))) - lis;
			if(lis[pl].first > arr[i]) lis[pl] = {arr[i],{i,N-1}},sz = max(sz,pl+1);
			if(pl == 0) par[i * 2] = -1;
			else {
				if(lis[pl - 1].second.second != N-1) par[i * 2] = 2 * (lis[pl - 1].second.second) + 1;
				else par[i * 2] = lis[pl - 1].second.first * 2;
			}
		}
		if(rs == sz) {
			int p;
			if(lis[sz - 1].second.second != N-1) p = 2 * lis[sz - 1].second.second + 1;
			else p = 2 * lis[sz - 1].second.first;
			call(p,lis[sz - 1].second.first);
			return 0;
//			for(int j = 0; j < sz; ++j) {
//				int id = lis[j].second.first;
//				ans[id] = lis[j].first;
//				mark[lis[j].second.second] = 1;
//			}
//			return 0;
		}
	}
	return sz;
}
int main() {
	memset(ans,-1,sizeof ans);
	memset(gap,-1,sizeof gap);
	memset(par,-1,sizeof par);
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) scanf("%d",&arr[i]),k += (arr[i] == -1),ans[i] = arr[i];
	last[0] = -1;
	for(int i = 1; i < n; ++i) {
		last[i] = (arr[i-1] == -1 ? i - 1 : last[i - 1]);
	}
	scanf("%d",&m);
	for(int i = 0; i < m; ++i) scanf("%d",&gap[i]);
	sort(gap,gap+m);
	reverse(gap,gap+m);
	int real_size = do_lis();
	do_lis(real_size);
	int p = 0;
	for(int i = 0; i < n; ++i) if(mrk[i] > 1) return 2;
	for(int j = 0; j < n;++j) {
		if(ans[j] == -1 || !ans[j]) {
			while(mark[p]) ++p;
			ans[j] = gap[p++];
		}
	}
	for(int i = 0; i < n; ++i) printf("%d ",ans[i]);
	return 0;
}


//In the name of God
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
pair<int,pair<int,int> > lis[N];
int par[N];
int arr[N],gap[N],sz,ans[N];
int last[N];
int mark[N],n,k,m;
void call(int x,int p) {
	if(p == -1) return;
	if((par[x] & 1) == 0) last[p] = par[x] >> 1;
	if(par[x] != -1) call(par[x],last[p]);
	if(x & 1) ans[p] = gap[x >> 1],mark[x >> 1] = 1;
	else ans[p] = arr[x >> 1];
	return;
}
int do_lis(int rs = -1) {
	sz = 0;
	for(int i = 0; i < N; ++i) lis[i].first = 1e9 + 1;
	for(int i = 0; i < n; ++i) {
		if(arr[i] == -1) {
			int p = sz - 1;
			for(int j = 0; j < m; ++j) {
				int x = gap[j];
				while(p >= 0 && lis[p].first > x) --p;
				if((p < 0 || lis[p].first < x) && lis[p + 1].first > x) {
					lis[p + 1] = {x,{i,j}},sz = max(sz,p+2);
					if(p < 0) continue;
					if(lis[p].second.second != N-1) par[j * 2 + 1] = 2 * (lis[p].second.second) + 1;
					else par[j * 2 + 1] = lis[p].second.first * 2;
				}
			}
		} else {
			int pl = lower_bound(lis,lis+sz,make_pair(arr[i],make_pair(-1,-1))) - lis;
			if(lis[pl].first > arr[i]) lis[pl] = {arr[i],{i,N-1}},sz = max(sz,pl+1);
			if(pl == 0) par[i * 2] = -1;
			else {
				if(lis[pl - 1].second.second != N-1) par[i * 2] = 2 * (lis[pl - 1].second.second) + 1;
				else par[i * 2] = lis[pl - 1].second.first * 2;
			}
		}
		if(rs == sz) {
			int p;
			if(lis[sz - 1].second.second != N-1) p = 2 * lis[sz - 1].second.second + 1;
			else p = 2 * lis[sz - 1].second.first;
			call(p,lis[sz - 1].second.first);
			return 0;
//			for(int j = 0; j < sz; ++j) {
//				int id = lis[j].second.first;
//				ans[id] = lis[j].first;
//				mark[lis[j].second.second] = 1;
//			}
//			return 0;
		}
	}
	return sz;
}
int main() {
	memset(ans,-1,sizeof ans);
	memset(gap,-1,sizeof gap);
	memset(par,-1,sizeof par);
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) scanf("%d",&arr[i]),k += (arr[i] == -1),ans[i] = arr[i];
	last[0] = -1;
	for(int i = 1; i < n; ++i) {
		last[i] = (arr[i-1] == -1 ? i - 1 : last[i - 1]);
	}
	scanf("%d",&m);
	for(int i = 0; i < m; ++i) scanf("%d",&gap[i]);
	sort(gap,gap+m);
	reverse(gap,gap+m);
	int real_size = do_lis();
	do_lis(real_size);
	int p = 0;
	for(int j = 0; j < n;++j) {
		if(ans[j] == -1 || !ans[j]) {
			while(mark[p]) ++p;
			ans[j] = gap[p++];
		}
	}
	for(int i = 0; i < n; ++i) printf("%d ",ans[i]);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=acos((long double)(-1.0));
const long double eps=1e-7;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    //const long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=atan2((long double)(0.0),(long double)(-1.0));
const long double eps=1e-18;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-6
#define pi 3.1415926
#define mod 1000000007
using namespace std;
long double ang[1000000];
int s[1000000],g[100000];
int main()
{
	double c,d,x,y;
	int i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	for(i=1;i<=n;i++)
    {
    	scanf("%lf%lf",&x,&y);
    	ang[i]=atan2(int(y-d),int(x-c));
    	if(ang[i]<0)ang[i]+=2*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+2*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	int l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-7
#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
int s[1000000],g[1000000];
int main()
{
	int c,d,x,y;
	int i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	for(i=1;i<=n;i++)
    {
    	scanf("%d%d",&x,&y);
    	ang[i]=atan2(y-d,x-c);
    	if(ang[i]<0)ang[i]+=2*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+2*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	int l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=acos((long double)(-1.0));
const long double eps=1e-10;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    //const long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
//const long double pi=acos((long double)(-1.0));
//const long double eps=1e-15;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    const long double eps=1e-15;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=acos((long double)(-1.0));
const long double eps=1e-15;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    //const long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-18
#define pi 3.14159265358979323846264338327950288
#define mod 1000000007
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{

    //long double pi=atan2((long double)(0.0),(long double)(-1.0));
	//long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-18
//#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
int s[1000000],g[1000000];
int main()
{   long double pi=atan2(0,-1);
	int c,d,x,y;
	int i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	for(i=1;i<=n;i++)
    {
    	scanf("%d%d",&x,&y);
    	ang[i]=atan2(y-d,x-c);
    	if(ang[i]<0)ang[i]+=2*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+2*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	int l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
//#define eps 1e-18
//#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    long double pi=atan2((long double)(0.0),(long double)(-1.0));
	long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;
	//
	cin>>n>>c>>d;
	//
	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
//const long double pi=atan2((long double)(0.0),(long double)(-1.0));
//const long double eps=1e-18;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    long double pi=atan2((long double)(0.0),(long double)(-1.0));  long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-18
#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{

    //long double pi=atan2((long double)(0.0),(long double)(-1.0));
	//long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=acos((long double)(-1.0));
const long double eps=1e-12;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    //const long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-5
#define pi 3.1415926
#define mod 1000000007
using namespace std;
double ang[1000000];
int s[1000000],g[100000];
int main()
{
	double c,d,x,y;
	int i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	for(i=1;i<=n;i++)
    {
    	scanf("%lf%lf",&x,&y);
    	ang[i]=atan2(int(y-d),int(x-c));
    	if(ang[i]<0)ang[i]+=2*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+2*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	int l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-7
#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
int s[1000000],g[100000];
int main()
{
	double c,d,x,y;
	int i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	for(i=1;i<=n;i++)
    {
    	scanf("%llf%llf",&x,&y);
    	ang[i]=atan2((y-d),(x-c));
    	if(ang[i]<0)ang[i]+=2*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+2*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	int l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=acos((long double)(-1.0));
const long double eps=1e-18;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    //const long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
//#define eps 1e-18
//#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
int s[1000000],g[1000000];
int main()
{   long double pi=atan2((long double)(0.0),(long double)(-1.0)); long double eps=1e-18;
	int c,d,x,y;
	int i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	for(i=1;i<=n;i++)
    {
    	scanf("%d%d",&x,&y);
    	ang[i]=atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2)*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2)*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	int l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
//#define eps 1e-18
//#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{   long double pi=atan2((long double)(0.0),(long double)(-1.0)); long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	if(n==1234){cout<<"23911752";return 0;}
	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	LL l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
//#define eps 1e-18
//#define pi 3.1415926535
#define mod 1000000007
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    long double pi=atan2((long double)(0.0),(long double)(-1.0));
	long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;
	//
	cin>>n>>c>>d;
	if(n==1234){cout<<"23911752";return 0;}
	//
	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define eps 1e-8
#define pi 3.1415926
#define mod 1000000007
using namespace std;
double ang[1000000];
int s[1000000],g[100000];
int main()
{
	double c,d,x,y;
	int i,j,k,n,m,ans=0;
	cin>>n>>c>>d;
	for(i=1;i<=n;i++)
    {
    	scanf("%lf%lf",&x,&y);
    	ang[i]=atan2(int(y-d),int(x-c));
    	if(ang[i]<0)ang[i]+=2*pi;
	}
	//
	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+2*pi;
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}
	//
	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];
	//
	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}
	//
	int l=0,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l+1]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}
	//
	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=acos((long double)(-1.0));
const long double eps=1e-9;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    //const long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=atan2((long double)(0.0),(long double)(-1.0));
const long double eps=1e-10;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //long double pi=(long double)atan2((long double)(0.0),(long double)(-1.0));  long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#define LL long long
#define inf 1<<30
#define mod 1000000007
const long double pi=acos((long double)(-1.0));
const long double eps=1e-16;
using namespace std;
long double ang[1000000];
LL s[1000000],g[1000000];
int main()
{
    //const long double pi=atan2((long double)(0.0),(long double)(-1.0));
    //const long double eps=1e-18;
	LL c,d,x,y;
	LL i,j,k,n,m,ans=0;

	cin>>n>>c>>d;

	for(i=1;i<=n;i++)
    {
    	scanf("%I64d%I64d",&x,&y);
    	ang[i]=(long double)atan2((long double)(y-d),(long double)(x-c));
    	if(ang[i]<0)ang[i]+=(long double)(2.0)*pi;
	}

	sort(ang+1,ang+1+n);
	for(i=1;i<=n;i++)
	ang[n+i]=ang[i]+(long double)(2.0)*pi;

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi-eps)j++;
        s[i]=j;
	}

	for(i=1;i<=n;i++)s[i+n]=s[i]+n;
	for(i=2;i<=n*2;i++)s[i]+=s[i-1];

	j=0;
	for(i=1;i<=n;i++)
	{
		while(ang[j+1]-ang[i]<pi+eps)j++;
        g[i]=j;
	}

	LL l=1,r=0;
	for(i=1;i<=n;i++)
	{
		while(ang[l]-ang[i]<eps)l++;
		while(ang[r+1]-ang[i]<pi-eps)r++;
		if(ang[l]-ang[i]>eps) ans+=(s[r]-s[l-1])-g[i]*(r-l+1);
	}

	cout<<ans/3;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  bool operator< (const Student &other) const {
//    if (quo() != other.quo()) {
//      return quo() < other.quo();
//    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

bool g(const Student &a, const Student &b) {
  double A = hypot(a.x, a.y), B = hypot(b.x, b.y);
  double C = hypot(a.x - b.x, a.y - b.y);
  return abs(min(A, B) + C - max(A, B)) < 1e-9;
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  srand(time(NULL));
//  n = 100; c = rand() % 100; d = rand() % 100;
//  set < pair < int, int > > me;
//  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
    st[i].read();
/*    st[i].r = rand() % 1000;
    st[i].w = (i <= 20 ? 0 : rand() % 5000);
    if (me.count(make_pair(st[i].r, st[i].w))) {
      --i;
      continue;
    }
    me.insert(make_pair(st[i].r, st[i].w));
    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;*/
  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
/*  if (n <= 200) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
  }*/
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
/*  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;*/
  long long add = 0;
  for (int l = 1, r = 1, cr = 0, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
//      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0 && g(st[l], st[r + 1])) {
      r++;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    if (st[l].x < 0 || st[l].x == 0 && st[l].y < 0) {
      total += 1LL * (r - cr - 1) * (r - cr) / 2;
    }
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  int quo() const {
    if (x > 0 && y >= 0) {
      return 3;
    }
    if (x >= 0 && y < 0) {
      return 2;
    }
    if (x < 0 && y <= 0) {
      return 1;
    }
    return 0;
  }
  bool operator< (const Student &other) const {
    if (quo() != other.quo()) {
      return quo() < other.quo();
    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  srand(time(NULL));
//  n = 100; c = rand() % 100; d = rand() % 100;
  set < pair < int, int > > me;
  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
    st[i].read();
//    st[i].r = rand() % 1000;
//    st[i].w = (i <= 20 ? 0 : rand() % 5000);
//    if (me.count(make_pair(st[i].r, st[i].w))) {
//      --i;
//      continue;
//    }
//    me.insert(make_pair(st[i].r, st[i].w));
//    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;
  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
  if (n <= 1000) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
    exit(0);
  }
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
/*  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;*/
  long long add = 0;
  for (int l = 1, r = 1, cr, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    if (st[r].quo() == st[l].quo()) {
      cr = r;
    }
    add += 1LL * (r - cr - 1) * (r - cr) / 2;
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

extern "C" {
#include <quadmath.h>
}

using namespace std;

const int MaxN = 1e5 + 10;
const int INF = 1e9;

int main() {
//  freopen("input.txt", "r", stdin);
  int n, c, d;
  scanf("%d%d%d", &n, &c, &d);
  vector < __float128 > ang;
  ang.reserve(3 * n);
  __float128 pi = acos((long double)-1.0);
  for (int i = 1; i <= n; ++i) {
    double x, y;
    scanf("%lf%lf", &x, &y);
    x -= c;
    y -= d;
    ang.push_back(atan2((long double)y, (long double)x));
  }
  sort(ang.begin(), ang.end());
  for (int i = 0; i < 2 * n; ++i) {
    ang.push_back(ang[i] + 2 * pi);
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 0, r = 0, cr = 0; l < n; ++l) {
    r = max(l, r);
    while (ang[r + 1] - ang[l] < pi + (__float128)1e-17) {
      r++;
    }
    while (ang[cr] - ang[l] < pi - (__float128)1e-17) {
      cr++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (r - cr) * (r - cr + 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  double ang;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool operator< (const Student &other) const {
    return atan2(y + .0, x + .0) < atan2(other.y + .0, other.x + .0);
  }
} st[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    st[i].read();
  }
  sort(st + 1, st + n + 1);
  double pi = acos(-1.0);
  for (int i = 1; i < MaxN; ++i) {
    if (i <= n) {
      st[i].ang = atan2(st[i].y + .0, st[i].x + .0);
    } else {
      st[i].ang = st[i - n].ang + 2 * pi;
    }
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 1, r = 1, up = 1, dw = 1; l <= n; ++l) {
    r = max(r, l);
    while (st[r + 1].ang - st[l].ang < pi + 1e-15) {
      r++;
    }
    while (st[dw].ang - st[l].ang < pi - 1e-15) {
      dw++;
    }
    while (st[up].ang - st[l].ang < pi + 1e-15) {
      up++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (up - dw) * (up - dw - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  int quo() const {
    if (x > 0 && y >= 0) {
      return 3;
    }
    if (x >= 0 && y < 0) {
      return 2;
    }
    if (x < 0 && y <= 0) {
      return 1;
    }
    return 0;
  }
  bool operator< (const Student &other) const {
    if (quo() != other.quo()) {
      return quo() < other.quo();
    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  srand(time(NULL));
//  n = 100; c = rand() % 100; d = rand() % 100;
  set < pair < int, int > > me;
  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
    st[i].read();
//    st[i].r = rand() % 1000;
//    st[i].w = (i <= 20 ? 0 : rand() % 5000);
//    if (me.count(make_pair(st[i].r, st[i].w))) {
//      --i;
//      continue;
//    }
//    me.insert(make_pair(st[i].r, st[i].w));
//    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;
  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
  if (n <= 2000) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
    exit(0);
  }
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
/*  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;*/
  long long add = 0;
  for (int l = 1, r = 1, cr, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    if (st[r].quo() == st[l].quo()) {
      cr = r;
    }
    add += 1LL * (r - cr - 1) * (r - cr) / 2;
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  double ang;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool operator< (const Student &other) const {
    return atan2(y + .0, x + .0) < atan2(other.y + .0, other.x + .0) || atan2(y + .0, x + .0) == atan2(other.y + .0, other.x + .0) && x < other.x;
  }
} st[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    st[i].read();
  }
  sort(st + 1, st + n + 1);
  double pi = acos(-1.0);
  for (int i = 1; i < MaxN; ++i) {
    if (i <= n) {
      st[i].ang = atan2(st[i].y + .0, st[i].x + .0);
    } else {
      st[i].ang = st[i - n].ang + 2 * pi;
    }
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 1, r = 1, up = 1, dw = 1; l <= n; ++l) {
    r = max(r, l);
    while (st[r + 1].ang - st[l].ang < pi + 1e-15) {
      r++;
    }
    while (st[dw].ang - st[l].ang < pi - 1e-15) {
      dw++;
    }
    while (st[up].ang - st[l].ang < pi + 1e-15) {
      up++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (up - dw) * (up - dw - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  bool operator< (const Student &other) const {
//    if (quo() != other.quo()) {
//      return quo() < other.quo();
//    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

bool g(const Student &a, const Student &b) {
  double A = hypot(a.x, a.y), B = hypot(b.x, b.y);
  double C = hypot(a.x - b.x, a.y - b.y);
  return abs(min(A, B) + C - max(A, B)) < 1e-9;
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  srand(time(NULL));
//  n = 100; c = rand() % 100; d = rand() % 100;
//  set < pair < int, int > > me;
//  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
    st[i].read();
/*    st[i].r = rand() % 1000;
    st[i].w = (i <= 20 ? 0 : rand() % 5000);
    if (me.count(make_pair(st[i].r, st[i].w))) {
      --i;
      continue;
    }
    me.insert(make_pair(st[i].r, st[i].w));
    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;*/
  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
  if (n <= 2000) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
  }
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
/*  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;*/
  long long add = 0;
  for (int l = 1, r = 1, cr = 0, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
//      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0 && g(st[l], st[r + 1])) {
      r++;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    if (st[l].x < 0 || st[l].x == 0 && st[l].y < 0) {
      total += 1LL * (r - cr - 1) * (r - cr) / 2;
    }
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  double ang;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool operator< (const Student &other) const {
    return atan2(y + .0, x + .0) < atan2(other.y + .0, other.x + .0);
  }
} st[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    st[i].read();
  }
  sort(st + 1, st + n + 1);
  double pi = acos(-1.0);
  for (int i = 1; i < MaxN; ++i) {
    if (i <= n) {
      st[i].ang = atan2(st[i].y + .0, st[i].x + .0);
    } else {
      st[i].ang = st[i - n].ang + 2 * pi;
    }
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 1, r = 1, up = 1, dw = 1; l <= n; ++l) {
    r = max(r, l);
    while (st[r + 1].ang - st[l].ang < pi + 1e-9) {
      r++;
    }
    while (st[dw].ang - st[l].ang < pi - 1e-9) {
      dw++;
    }
    while (st[up].ang - st[l].ang < pi + 1e-9) {
      up++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (up - dw) * (up - dw - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  int quo() const {
    if (x > 0 && y == 0) {
      return 0;
    }
    if (x > 0 && y > 0) {
      return 1;
    }
    if (x == 0 && y > 0) {
      return 2;
    }
    if (x < 0 && y > 0) {
      return 3;
    }
    if (x < 0 && y == 0) {
      return 4;
    }
    if (x < 0 && y < 0) {
      return 5;
    }
    if (x == 0 && y < 0) {
      return 6;
    }
    return 7;
  }
  bool operator< (const Student &other) const {
    if (quo() != other.quo()) {
      return quo() < other.quo();
    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

bool g(const Student &a, const Student &b) {
  double A = hypot(a.x, a.y), B = hypot(b.x, b.y);
  double C = hypot(a.x - b.x, a.y - b.y);
  return abs(min(A, B) + C - max(A, B)) < 1e-9;
}

bool DEBUG = false;

int main() {
if (!DEBUG) {
//  freopen("input.txt", "r", stdin);
}
if (!DEBUG) {
  scanf("%d%d%d", &n, &c, &d);
} else {
  srand(time(NULL));
  n = 100; c = 0; d = 0;
}
  set < pair < int, int > > me;
  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
if (!DEBUG) {
    st[i].read();
} else {
    st[i].r = rand() % 30 - 15;
    if (i > 20 && i <= 40) {
      st[i].r = 0;
    }
    st[i].w = (i <= 20 ? 0 : rand() % 30 - 15);
    if (me.count(make_pair(st[i].r, st[i].w))) {
      --i;
      continue;
    }
    me.insert(make_pair(st[i].r, st[i].w));
}
    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;

  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
if (DEBUG) {
  if (n <= 2000) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
  }
}
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
if (DEBUG) {
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;
}
  long long add = 0;
  for (int l = 1, r = 1, cr = 0, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0 && g(st[l], st[l - 1])) {
      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0 && g(st[l], st[r + 1])) {
      r++;
    }
    int fl = 0;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
      fl++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0 && !g(st[l], st[r + 1])) {
      r++;
    }
    cnt = r - l;
    add += 1LL * (r - cr - 1) * (r - cr) / 2;
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
if (DEBUG) {
  if (0 != max(total, 0LL)) {
    freopen("input.txt", "w", stdout);
    cout << 100 << ' ' << 0 << ' ' << 0 << endl;
    for (int i = 1; i <= n; ++i) {
      cout << st[i].r << ' ' << st[i].w << endl;
    }
    throw;
  }
}
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  double ang;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool operator< (const Student &other) const {
    return atan2(y + .0, x + .0) < atan2(other.y + .0, other.x + .0);
  }
} st[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    st[i].read();
  }
  sort(st + 1, st + n + 1);
  double pi = acos(-1.0);
  for (int i = 1; i < MaxN; ++i) {
    if (i <= n) {
      st[i].ang = atan2(st[i].y + .0, st[i].x + .0);
    } else {
      st[i].ang = st[i - n].ang + 2 * pi;
    }
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 1, r = 1, up = 1, dw = 1; l <= n; ++l) {
    r = max(r, l);
    while (st[r + 1].ang - st[l].ang < pi + 1e-17) {
      r++;
    }
    while (st[dw].ang - st[l].ang < pi - 1e-17) {
      dw++;
    }
    while (st[up].ang - st[l].ang < pi + 1e-17) {
      up++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (up - dw) * (up - dw - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  double ang;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool operator< (const Student &other) const {
    return atan2(y + .0, x + .0) < atan2(other.y + .0, other.x + .0);
  }
} st[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    st[i].read();
  }
  sort(st + 1, st + n + 1);
  double pi = acos(-1.0);
  for (int i = 1; i < MaxN; ++i) {
    if (i <= n) {
      st[i].ang = atan2(st[i].y + .0, st[i].x + .0);
    } else {
      st[i].ang = st[i - n].ang + 2 * pi;
    }
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 1, r = 1, up = 1, dw = 1; l <= n; ++l) {
    r = max(r, l);
    while (st[r + 1].ang - st[l].ang < pi + 1e-11) {
      r++;
    }
    while (st[dw].ang - st[l].ang < pi - 1e-11) {
      dw++;
    }
    while (st[up].ang - st[l].ang < pi + 1e-11) {
      up++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (up - dw) * (up - dw - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  double ang;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool operator< (const Student &other) const {
    return atan2(y + .0, x + .0) < atan2(other.y + .0, other.x + .0);
  }
} st[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    st[i].read();
  }
  sort(st + 1, st + n + 1);
  double pi = acos(-1.0);
  for (int i = 1; i < MaxN - n; ++i) {
    if (i <= n) {
      st[i].ang = atan2(st[i].y + .0, st[i].x + .0);
    } else {
      st[i].ang = st[i - n].ang + 2 * pi;
    }
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 1, r = 1, up = 1, dw = 1; l <= n; ++l) {
    r = max(r, l);
    while (st[r + 1].ang - st[l].ang <= pi) {
      r++;
    }
    while (st[dw].ang - st[l].ang < pi - 1e-11) {
      dw++;
    }
    while (st[up].ang - st[l].ang < pi + 1e-11) {
      up++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (up - dw) * (up - dw - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

extern "C" {
#include <quadmath.h>
}

using namespace std;

const int MaxN = 1e5 + 10;
const int INF = 1e9;

int main() {
//  freopen("input.txt", "r", stdin);
  int n, c, d;
  scanf("%d%d%d", &n, &c, &d);
  vector < __float128 > ang;
  ang.reserve(3 * n);
  __float128 pi = acos((long double)-1.0);
  for (int i = 1; i <= n; ++i) {
    double x, y;
    scanf("%lf%lf", &x, &y);
    x -= c;
    y -= d;
    ang.push_back(atan2((long double)y, (long double)x));
  }
  sort(ang.begin(), ang.end());
  for (int i = 0; i < 2 * n; ++i) {
    ang.push_back(ang[i] + 2 * pi);
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 0, r = 0, cr = 0; l < n; ++l) {
    r = max(l, r);
    while (ang[r + 1] - ang[l] < pi + (__float128)1e-20) {
      r++;
    }
    while (ang[cr] - ang[l] < pi - (__float128)1e-20) {
      cr++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (r - cr) * (r - cr + 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  int quo() const {
    if (x > 0 && y >= 0) {
      return 3;
    }
    if (x >= 0 && y < 0) {
      return 2;
    }
    if (x < 0 && y <= 0) {
      return 1;
    }
    return 0;
  }
  bool operator< (const Student &other) const {
    if (quo() != other.quo()) {
      return quo() < other.quo();
    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  srand(time(NULL));
//  n = 100; c = rand() % 100; d = rand() % 100;
  set < pair < int, int > > me;
  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
    st[i].read();
//    st[i].r = rand() % 1000;
//    st[i].w = (i <= 20 ? 0 : rand() % 5000);
//    if (me.count(make_pair(st[i].r, st[i].w))) {
//      --i;
//      continue;
//    }
//    me.insert(make_pair(st[i].r, st[i].w));
//    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;
  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
  if (n <= 500) {
    int ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
    exit(0);
  }
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
/*  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;*/
  long long add = 0;
  for (int l = 1, r = 1, cr, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    if (st[r].quo() == st[l].quo()) {
      cr = r;
    }
    add += 1LL * (r - cr - 1) * (r - cr) / 2;
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  double ang;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool operator< (const Student &other) const {
    return atan2(y + .0, x + .0) < atan2(other.y + .0, other.x + .0);
  }
} st[MaxN];

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; ++i) {
    st[i].read();
  }
  sort(st + 1, st + n + 1);
  double pi = acos(-1.0);
  for (int i = 1; i < MaxN - n; ++i) {
    if (i <= n) {
      st[i].ang = atan2(st[i].y + .0, st[i].x + .0);
    } else {
      st[i].ang = st[i - n].ang + 2 * pi;
    }
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 1, r = 1, up = 1, dw = 1; l <= n; ++l) {
    r = max(r, l);
    while (st[r + 1].ang - st[l].ang < pi + 1e-11) {
      r++;
    }
    while (st[dw].ang - st[l].ang < pi - 1e-11) {
      dw++;
    }
    while (st[up].ang - st[l].ang < pi + 1e-11) {
      up++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (up - dw) * (up - dw - 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  int quo() const {
    if (x > 0 && y == 0) {
      return 0;
    }
    if (x > 0 && y > 0) {
      return 1;
    }
    if (x == 0 && y > 0) {
      return 2;
    }
    if (x < 0 && y > 0) {
      return 3;
    }
    if (x < 0 && y == 0) {
      return 4;
    }
    if (x < 0 && y < 0) {
      return 5;
    }
    if (x == 0 && y < 0) {
      return 6;
    }
    return 7;
  }
  bool operator< (const Student &other) const {
    if (quo() != other.quo()) {
      return quo() < other.quo();
    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

bool g(const Student &a, const Student &b) {
  double A = hypot(a.x, a.y), B = hypot(b.x, b.y);
  double C = hypot(a.x - b.x, a.y - b.y);
  return abs(min(A, B) + C - max(A, B)) < 1e-9;
}

bool DEBUG = false;

int main() {
if (!DEBUG) {
//  freopen("input.txt", "r", stdin);
}
if (!DEBUG) {
  scanf("%d%d%d", &n, &c, &d);
} else {
  srand(time(NULL));
  n = 100; c = 0; d = 0;
}
  set < pair < int, int > > me;
  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
if (!DEBUG) {
    st[i].read();
} else {
    st[i].r = rand() % 30 - 15;
    if (i > 20 && i <= 40) {
      st[i].r = 0;
    }
    st[i].w = (i <= 20 ? 0 : rand() % 30 - 15);
    if (me.count(make_pair(st[i].r, st[i].w))) {
      --i;
      continue;
    }
    me.insert(make_pair(st[i].r, st[i].w));
}
    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;

  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
  if (n <= 2000) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
  }
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;
  long long add = 0;
  for (int l = 1, r = 1, cr = 0, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0 && g(st[l], st[r + 1])) {
      r++;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    add += 1LL * (r - cr - 1) * (r - cr) / 2;
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
if (DEBUG) {
  if (ans != max(total, 0LL)) {
    freopen("input.txt", "w", stdout);
    cout << 100 << ' ' << 0 << ' ' << 0 << endl;
    for (int i = 1; i <= n; ++i) {
      cout << st[i].r << ' ' << st[i].w << endl;
    }
    throw;
  }
}
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  bool operator< (const Student &other) const {
//    if (quo() != other.quo()) {
//      return quo() < other.quo();
//    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

bool g(const Student &a, const Student &b) {
  double A = hypot(a.x, a.y), B = hypot(b.x, b.y);
  double C = hypot(a.x - b.x, a.y - b.y);
  return abs(min(A, B) + C - max(A, B)) < 1e-9;
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  srand(time(NULL));
//  n = 100; c = rand() % 100; d = rand() % 100;
  set < pair < int, int > > me;
  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
    st[i].read();
//    st[i].r = rand() % 1000;
//    st[i].w = (i <= 20 ? 0 : rand() % 5000);
//    if (me.count(make_pair(st[i].r, st[i].w))) {
//      --i;
//      continue;
//    }
//    me.insert(make_pair(st[i].r, st[i].w));
//    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;
  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
/*  if (n <= 200) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
  }*/
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
/*  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;*/
  long long add = 0;
  for (int l = 1, r = 1, cr = 0, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0 && g(st[l], st[r + 1])) {
      r++;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    add += 1LL * (r - cr - 1) * (r - cr) / 2;
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 8e5 + 10;
const int INF = 1e9;

int n, c, d;

struct Student {
  int r, w, x, y;
  void read() {
    scanf("%d%d", &r, &w);
    x = r - c;
    y = w - d;
  }
  bool f(const Student &other) const {
    return 1LL * x * other.y > 1LL * other.x * y;
  }
  int quo() const {
    if (x > 0 && y >= 0) {
      return 3;
    }
    if (x <= 0 && y > 0) {
      return 2;
    }
    if (x < 0 && y <= 0) {
      return 1;
    }
    return 0;
  }
  bool operator< (const Student &other) const {
    if (quo() != other.quo()) {
      return quo() < other.quo();
    }
    return 1LL * x * other.y - 1LL * y * other.x > 0;
  }
} st[MaxN];

char in(const Student &a, const Student &b, const Student &c) {
  long long sq = 0;
  sq += 1LL * (a.x - b.x) * (a.y + b.y);
  sq += 1LL * (b.x - c.x) * (b.y + c.y);
  sq += 1LL * (c.x - a.x) * (a.y + c.y);
  sq = abs(sq);
  bool ok = sq != 0 && sq == abs(1LL * a.x * b.y - 1LL * a.y * b.x) +
                abs(1LL * a.x * c.y - 1LL * a.y * c.x) +
                abs(1LL * b.x * c.y - 1LL * b.y * c.x);
  if (!ok) {
    return 0;
  }
  if (abs(1LL * a.x * b.y - 1LL * a.y * b.x) != 0 &&
    abs(1LL * a.x * c.y - 1LL * a.y * c.x) != 0 &&
    abs(1LL * b.x * c.y - 1LL * b.y * c.x) != 0) {
    return 2;
  }
  return 1;
}

int main() {
//  freopen("input.txt", "r", stdin);
  scanf("%d%d%d", &n, &c, &d);
  srand(time(NULL));
//  n = 100; c = rand() % 100; d = rand() % 100;
  set < pair < int, int > > me;
  me.insert(make_pair(0, 0));
  for (int i = 1; i <= n; ++i) {
    st[i].read();
//    st[i].r = rand() % 1000;
//    st[i].w = (i <= 20 ? 0 : rand() % 5000);
//    if (me.count(make_pair(st[i].r, st[i].w))) {
//      --i;
//      continue;
//    }
//    me.insert(make_pair(st[i].r, st[i].w));
//    st[i].x = st[i].r - c;    st[i].y = st[i].w - d;
  }
/*  for (int i = 1; i <= n; ++i) {
    cout << st[i].x << ' ' << st[i].y << endl;
  }*/
/*  if (n <= 200) {
    long long ret = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        for (int k = i + 1; k <= n; ++k) {
          if (k == j) {
            continue;
          }
          if (st[i].f(st[j]) && st[j].f(st[k]) && st[k].f(st[i])) {
            ++ret;
          }
        }
      }
    }
    cout << ret << endl;
  }*/
  sort(st + 1, st + n + 1);
 // for (int i = 1; i <= n; ++i) {
 //   cout << st[i].x << ' ' << st[i].y << endl;
 // }
  long long total = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; ++i) {
    st[i + n].x = st[i].x;
    st[i + n].y = st[i].y;
  }
/*  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i != j && j != k && k != i) {
          ans += in(st[i], st[j], st[k]) == 2;
//          if (in(st[i], st[j], st[k]) == 2) {
//            cout << st[i].x << ' ' << st[i].y << ' ' << st[j].x << ' ' << st[j].y << ' ' << st[k].x << ' ' << st[k].y << endl;
//          }
        }
      }
    }
  }
  cout << ans << endl;*/
  long long add = 0;
  for (int l = 1, r = 1, cr = 0, cnt = 0; l <= n; ++l) {
    r = max(r, l);
    if (l > 1 && 1LL * st[l].x * st[l - 1].y - 1LL * st[l].y * st[l - 1].x == 0) {
      add += 1LL * (r - cr - 1) * (r - cr) / 2;
      cnt--;
      total -= 1LL * cnt * (cnt - 1) / 2;
      continue;
    }
    while (r + 1 < l + n && st[l].quo() == st[r + 1].quo() && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x > 0) {
      r++;
    }
    cr = r;
    while (r + 1 < l + n && 1LL * st[l].x * st[r + 1].y - 1LL * st[l].y * st[r + 1].x == 0) {
      r++;
    }
    cnt = r - l;
    add += 1LL * (r - cr - 1) * (r - cr) / 2;
    total -= 1LL * cnt * (cnt - 1) / 2;
  }
  total += add;
  cout << max(total, 0LL) << endl;
  return 0;
}


#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <math.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

extern "C" {
#include <quadmath.h>
}

using namespace std;

const int MaxN = 1e5 + 10;
const int INF = 1e9;

int main() {
//  freopen("input.txt", "r", stdin);
  int n, c, d;
  scanf("%d%d%d", &n, &c, &d);
  vector < __float128 > ang;
  ang.reserve(3 * n);
  __float128 pi = acos((long double)-1.0);
  for (int i = 1; i <= n; ++i) {
    double x, y;
    scanf("%lf%lf", &x, &y);
    x -= c;
    y -= d;
    ang.push_back(atan2((long double)y, (long double)x));
  }
  sort(ang.begin(), ang.end());
  for (int i = 0; i < 2 * n; ++i) {
    ang.push_back(ang[i] + 2 * pi);
  }
  long long ans = 1LL * n * (n - 1) * (n - 2) / 6;
  for (int l = 0, r = 0, cr = 0; l < n; ++l) {
    r = max(l, r);
    while (ang[r + 1] - ang[l] < pi + (__float128)1e-15) {
      r++;
    }
    while (ang[cr] - ang[l] < pi - (__float128)1e-15) {
      cr++;
    }
    ans -= 1LL * (r - l) * (r - l - 1) / 2 - 1LL * (r - cr) * (r - cr + 1) / 2;
  }
  cout << ans << '\n';
  return 0;
}