vector v[1d5+1]; ll bs[1d5]; ll ad,as[1d5+1]; { int @n,@m; rd(bs(n)); rep(m){ ll @l,@r; v[l-1].push_back(r); } rep(i,0,n,2)bs[i]=-bs[i]; rep(x,n){ ad+=as[x]; if(v[x].empty()){ if(bs[x]!=ad){ wt("NO"); exit(0); } continue; } int r=v[x][0]; rep(y,1,v[x].size()){ int r2=v[x][y]; if(r>r2) swap(r,r2); v[r].push_back(r2); } v[x].clear(); as[r]-=bs[x]-ad; ad=bs[x]; } wt("YES"); }