#include <stdio.h>
#include <string.h>
#define MAX 32010
int lev[MAX],c[MAX];
int Lowbit(int x)
{
return x & (-x);
}
void Updata(int x)
{
while( x < MAX )
{
c[x]++;
x += Lowbit(x);
}
}
int Getsum(int x)
{
int sum = 0;
while( x > 0 )
{
sum += c[x];
x -= Lowbit(x);
}
return sum;
}
int main()
{
int n,x,y,i;
while( ~scanf("%d",&n) )
{
memset(lev,0,sizeof(lev));
memset(c,0,sizeof(c));
for(i=1; i<=n; i++)
{
scanf("%d%d",&x,&y);
x++;
lev[Getsum(x)]++;
Updata(x);
}
for(i=0; i<n; i++)
printf("%d\n",lev[i]);
}
return 0;
}
stars(树状数组)