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
#include <bits/stdc++.h>
#define qio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cerr<<#x<<" "<<x<<endl
#define ll long long 
#define st first
#define nd second
using namespace std;

ll n, t, a[300005], r[300005], x, bn, vis[300005];
vector <ll> V[300005], L;
string s, z;
map <string, ll> M;

void DFS(int v) {
	vis[v] = 1;
	s[v - 1] = '1';

	for (int i = 0; i < V[v].size(); i++) {
		if (vis[V[v][i]] == 0) DFS(V[v][i]);
	}
}

int main()
{
	qio;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> r[i];
	}

	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (a[i] + r[i] >= a[j]) V[i].push_back(j);
		}
		for (int j = i - 1; j >= 1; j--) {
			if (a[i] - r[i] <= a[j]) V[i].push_back(j);
		}
	}

	x = pow(2, n + 1) - 1;

	for (int i = 0; i <= x; i++) {
		L.clear();
		s.clear();
		bn = i;
		for (int j = 1; j <= n; j++) {
			vis[j] = 0;
		}
		while (bn > 0) {
			L.push_back(bn % 2);
			bn /= 2;
		}

		while (L.size() < n) L.push_back(0);
		while (s.size() < n) s += '0';

		for (int j = 0; j < n; j++) {
			if (L[j] == 1) DFS(j + 1);
		}
		M[s]++;
	}
	cout << M.size();

}