1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef double lf;
typedef long double llf;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
#define For(i,s,a) for(int i = (int)s; i < (int)a; ++i)
#define rpt(s, it) for(auto it = s.begin(); it != s.end(); ++it)
#define brpt(s, it) for(auto it = s.rend(); it != s.rbegin(); --it)
#define sz size()
#define pb push_back
#define eb emplace_back
#define ff first
#define dd second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ZAPS {int t; scanf("%i", &t); while(t--) solve();}
#define make_unique(x) (x).erase( unique(all(x)), (x).end())


template<typename Ta, typename Tb>
ostream & operator <<(ostream & os, pair<Ta, Tb> x){
	return os << x.ff << " " << x.dd;
}

const int N = 3e5 + 1;
const lld mod = 1e9 + 7;

lld pos[N], ran[N];
vector<int>c[N], rc[N];
int stos[N + 10], _end;
int color[N];
int cnt;
bitset<N>odw;
vector<int>sss[N];
bitset<N>is_top_elt;

void dfs(int x){
	odw[x] = 1;
	for(auto s : c[x])
		if(!odw[s])
			dfs(s);
	stos[++_end] = x;
}

void rdfs(int x, int col){
	color[x] = col;
	for(auto s : rc[x])
		if(color[s] == 0x3f3f3f3f)
			rdfs(s, col);
}

void make_sss(int n){
	_end = 0;
	cnt = -1;
	memset(color, 0x3f3f3f3f, sizeof(color));
	
	For(i, 0, n)
		if(!odw[i])
			dfs(i);
			
	while(_end){
		int x = stos[_end];
		if(color[x] == 0x3f3f3f3f)
			rdfs(x, ++cnt);
		--_end;
	}
	++cnt;
	For(i, 0, cnt)
		is_top_elt[i] = 1;
	
	For(x, 0, n)
		for(auto s : c[x])
			if(color[x] != color[s])
				sss[color[x]].pb(color[s]),
				is_top_elt[color[s]] = 0;
	
	For(x, 0, cnt)
		sort(all(sss[x])),
		make_unique(sss[x]);
		
	/*For(i, 0, cnt){
		cout<<i<<" "<<is_top_elt[i]<<"   ";
		for(auto s : sss[i])
			cout<<s<<" ";
		puts("");
	}*/
}

#define sumpair(x) ((x.ff + x.dd)) 

pll df_calc(int x){
	pll wyn = mp(1, 1);
	odw[x] = 1;
	for(auto s : sss[x])
		if(!odw[s])
			(wyn.ff *= sumpair(df_calc(s))) %= mod;
	return wyn;
}

int rea[N];
bitset<16777216>ok;
int dp[16777216];

void df_rea(int x, int src){
	odw[x] = 1;
	rea[src] |= (1 << x);
	for(auto s : sss[x])
		if(!odw[s])
			df_rea(s, src);
}

int solve(){
	For(i, 0, cnt){
		odw = 0;
		df_rea(i, i);
	}
	For(mask, 0, (1 << cnt)){
		dp[mask] = dp[mask ^ (mask & (-mask))] | rea[__builtin_ctz(mask & (-mask))];
		ok[dp[mask]] = 1;
	}
	return ok.count();
}

int32_t main(void){
	int n;
	scanf("%d", &n);
	For(i, 0, n)
		scanf("%lld%lld", &pos[i], &ran[i]);
	For(i, 0, n){
		int wsk = i - 1;
		while(wsk >= 0 && pos[wsk] + ran[i] >= pos[i]){
			c[i].pb(wsk);
			rc[wsk].pb(i);
			--wsk;
		}
		wsk = i + 1;
		while(wsk < n && pos[i] + ran[i] >= pos[wsk]){
			c[i].pb(wsk);
			rc[wsk].pb(i);
			++wsk;
		}
	}
	make_sss(n);
	printf("%d", solve());
}

/*
4
0  2
2  0
3  2
7  4
*/

/*
9
1 1
2 2
5 1
7 1
8 1
9 6
12 2
14 3
16 1
*/