The next lecture in a high school requires two topics to be discussed. The i�-th topic is interesting by ai�� units for the teacher and by bi�� units for the students.
The pair of topics i� and j� (i<j�<�) is called good if ai+aj>bi+bj��+��>��+�� (i.e. it is more interesting for the teacher).
Your task is to find the number of good pairs of topics.
Input
The first line of the input contains one integer n� (2≤n≤2⋅1052≤�≤2⋅105) — the number of topics.
The second line of the input contains n� integers a1,a2,…,an�1,�2,…,�� (1≤ai≤1091≤��≤109), where ai�� is the interestingness of the i�-th topic for the teacher.
The third line of the input contains n� integers b1,b2,…,bn�1,�2,…,�� (1≤bi≤1091≤��≤109), where bi�� is the interestingness of the i�-th topic for the students.
Output
Print one integer — the number of good pairs of topic.
Examples
input
Copy
5 4 8 2 6 2 4 5 4 1 3
output
Copy
7
input
Copy
4 1 3 2 4 1 3 2 4
output
Copy
0
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define PII pair<int,int>
#define IOS ios_base::sync_with_stdio(0);
int n,m,k,t;
struct node{
int a,b,c;
}s[200086];
bool cmp(node a,node b){
return a.c<b.c;
}
signed main(){
cin >> n;
for(int i=0;i<n;i++){
cin >> s[i].a;
}
for(int i=0;i<n;i++){
cin >> s[i].b;
s[i].c=s[i].a-s[i].b;
}
sort(s,s+n,cmp);
int sum=0;
for(int i=0;i<n;i++){
int l=0,r=n;
if(s[i].c<=0){
int a=0-s[i].c;
int p=0;
while(l!=r){
int mid= l+r >> 1;
if(s[mid].c>a){
p++;
r=mid;
}else{
l=mid+1;
}
}
if(p)sum+=n-l;
}else{
sum+=n-i-1;
}
// cout << l << " ans" << endl;
}
cout << sum << endl;
return 0;
}