#include using namespace std; #include #include #include #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF=1001001001; const int mod=1000000007; int main() { int N; cin>>N; vectorx(N),y(N); for(int i=0;i>x[i]>>y[i]; } priority_queue>>q; for(int i=0;iseen(N,false); int cnt=0; while(!q.empty()){ int d=q.top().first,i=q.top().second.first,j=q.top().second.second; q.pop(); if(i==0||j==0){ if(!seen[i+j-0]){cnt++;seen[i+j-0]=true;}//i+j-0=0の相方 } else if(!seen[i]&&!seen[j]){seen[i]=true;seen[j]=true;} } cout<