Harryxun/stf_run huggingface dataset:
N = int(input())
A = [0] + [int(_) for _ in input().split()]
B = [0]
if N == 1:
    print(1)
    exit()
is_monotonic_increasing = A[0] < A[1]
is_monotonic_decreasing = A[0] > A[1]
for i in range(1, N):
    if is_monotonic_increasing:
        is_monotonic_increasing &= A[i] < A[i + 1]
    elif is_monotonic_decreasing:
        is_monotonic_decreasing &= A[i] > A[i + 1]
    B += [min(A[i + 1], 18)]
if is_monotonic_increasing:
    print(1)
    exit()
if is_monotonic_decreasing:
    print(2)
    exit()


def is_possible(K):
    dp = [0] * 18
    for i in range(N):
        if B[i] >= B[i + 1]:
            dp = dp[:B[i + 1]] + [0] * (19 - B[i + 1])
            flag = True
            for j in range(B[i + 1] - 1, -1, -1):
                if dp[j] < K - 1:
                    dp[j] += 1
                    flag = False
                    break
                else:
                    dp[j] = 0
            if flag:
                return False
    return True


def bis(x, y):
    if y == x + 1:
        return y
    elif is_possible((x + y) // 2):
        return bis(x, (x + y) // 2)
    else:
        return bis((x + y) // 2, y)


print(bis(0, N))


### FIXED CODE ###

import random
input()
A = [int(_) for _ in input().split()]
A = [A[0]] + [j for i, j in zip(A, A[1:]) if i >= j]
N = len(A)


def cut(array, index):
    if index < 1:
        return []
    if index <= array[0][0]:
        return [(index, array[0][1])]
    for _ in range(len(array)-1, 0, -1):
        if array[_ - 1][0] < index:
            return array[:_] + [(index, array[_][1])]


def is_possible(K):
    dp = [(A[0], 0)]
    for a in A[1:]:
        if a <= dp[-1][0]:
            dp = cut(dp, a)
        else:
            dp += [(a, 0)]
        is_added = False
        for j in range(len(dp) - 1, -1, -1):
            if dp[j][1] < K - 1:
                dp = cut(dp, dp[j][0] - 1) + [(dp[j][0], dp[j][1] + 1)]
                if dp[-1][0] < a:
                    dp += [(a, 0)]
                is_added = True
                break
        if not is_added:
            return False
    return True


def bis(x, y):
    if y == x + 1:
        return y
    elif is_possible((x + y) // 2):
        return bis(x, (x + y) // 2)
    else:
        return bis((x + y) // 2, y)


print(bis(0, N))
N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
D = 0
i = 0

while D < X+1:
  D += L[i]
  i += 1
  count +=1
  
print(count)
  

### FIXED CODE ###

N,X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
D = 0

for i in range(N):
  D += L[i]
  if D <= X:
    count += 1
  else:
    break

print(count)
import sys
N, M, P = [int(x) for x in input().split()]
forward = {}
backward = {}
for _ in range(M):
  A, B, C = [int(x) for x in input().split()]
  forward[A] = forward.get(A, {})
  if B in forward[A]:
    forward[A][B] = max(forward[A][B], C-P)
  else:
    forward[A][B] = C-P
  backward[B] = backward.get(B, {})
  if A in backward[B]:
    backward[B][A] = max(backward[B][A], C-P)
  else:
    backward[B][A] = C-P
#print(forward)
#print(backward)
reachable = set([N])
to_track = set([N])
while to_track:
  x = to_track.pop()
  if x not in backward:
    continue
  for y in backward[x]:
    if y not in reachable:
      to_track.add(y)
      reachable.add(y)
#print(reachable)
if 1 not in reachable:
  print(-1)
  sys.exit()

forward = {k: {k2: v2 for k2, v2 in v.items() if k2 in reachable}
           for k, v in forward.items() if k in reachable}
#print(forward)
# backward = {k: {k2: v2 for k2, v2 in v.items() if k2 in reachable}
#            for k, v in backward.items() if k in reachable}
#print(backward)


reached = [0]  # score is not negative
def dfs(x, point, visited):
  #print(x,point,visited)
  if x == N:
    reached.append(point)
  if x not in forward:
    visited[x].pop()
    return
  #print(forward[x])
  for y, p in forward[x].items():
    if y in visited and visited[y]:
      #print(y, p, 'visited')
      for q in visited[y]:
        if point+p > q:
    #      print(x, y, p, point, visited)
          print(-1)
          sys.exit()
      visited[x].pop()
      return
    else:
      #print(y, p, 'to_visit')
      visited[y] = visited.get(y, [])
      visited[y].append(point+p)
      dfs(y, point+p, visited)
dfs(1, 0, {1: [0]})
#print(reached)
print(max(reached))

### FIXED CODE ###

import sys
N, M, P = [int(x) for x in input().split()]
forward = {}
backward = {}
for _ in range(M):
  A, B, C = [int(x) for x in input().split()]
  forward[A] = forward.get(A, {})
  if B in forward[A]:
    forward[A][B] = max(forward[A][B], C-P)
  else:
    forward[A][B] = C-P
  backward[B] = backward.get(B, {})
  if A in backward[B]:
    backward[B][A] = max(backward[B][A], C-P)
  else:
    backward[B][A] = C-P
#print(forward)
#print(backward)
reachable = set([N])
to_track = set([N])
while to_track:
  x = to_track.pop()
  if x not in backward:
    continue
  for y in backward[x]:
    if y not in reachable:
      to_track.add(y)
      reachable.add(y)
#print(reachable)
if 1 not in reachable:
  print(-1)
  sys.exit()

forward = {k: {k2: v2 for k2, v2 in v.items() if k2 in reachable}
           for k, v in forward.items() if k in reachable}
#print(forward)
# backward = {k: {k2: v2 for k2, v2 in v.items() if k2 in reachable}
#            for k, v in backward.items() if k in reachable}
#print(backward)

dist = {k: -float('inf') for k in reachable} 
dist[1] = 0
#print(reachable)
#print(dist)
#print(forward)
for _ in range(len(reachable)):
  renewed = False
  for x, y_dict in forward.items():
    for y in y_dict:
 #     print(x, y, forward[x][y], dist[x], dist[y])
      if dist[y] < dist[x] + forward[x][y]:
        renewed = True
        dist[y] = dist[x] + forward[x][y]
if renewed:
  # print('loop')
  print(-1)
else:
  print(max(0,dist[N]))
a,b,x = map(int, input().split())
if a!=0:
c = int((a-1)/x)
d = int(b/x)
if a!=0:
  print(d-c)
elif a==0:
  print(d)

### FIXED CODE ###

a, b, x = [ int(x) for x in input().split() ]

ans = int(b // x) - int((a - 1) // x)

print(ans)
foo=[0]*(300000)
bar=[0]*(300000)
n=int(raw_input())
for x in map(int,raw_input().split()):
    foo[x]+=1
n=int(raw_input())
for x in map(int,raw_input().split()):
    bar[x]+=1
for i in range(200001):
    if foo[i]<bar[i]:
        print "NO"
        exit(0)
print "YES"


### FIXED CODE ###

y=list(raw_input())
y.reverse()
foo=''
for i in range(len(y)):
    foo+=y[i]
    if foo=='LAVITSEF':
        j=i
        break
x=y[j+1:]
x.reverse()
print ''.join(x)
a = raw_input()
b = raw_input()
print int(a) * int(b)

print 2*(int(a) + int(b))

### FIXED CODE ###

a,b = map(int, raw_input().split())

print a*b, 2*(a+b)
N,X=map(int,input().split())
res=X-sum(m)
num=N
while res>min(m):
    c=math.floor(res/min(m))
    num+=c
    res=res-c*min(m)
print(num)
m=[int(input()) for i in range(N)]

### FIXED CODE ###

import math
N,X=map(int,input().split())
m=[int(input()) for i in range(N)]
res=X-sum(m)
num=N
while res>min(m):
    c=math.floor(res/min(m))
    num+=c
    res=res-c*min(m)
print(num)
import math

r = int( raw_input() ) 

S = math.pi * r ** 2 
l = 2 * r * math.pi

print"%f %f" %(S,l)

### FIXED CODE ###

import math

r = float( raw_input() ) 

S = math.pi * r * r
l = 2 * r * math.pi

print"%f %f" %(S,l)
N=int(input())
S=input()
if N%2 !=0:
  print("No")
elif S[:N/2]==S[N/2:]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N=int(input())
S=input()
X=int(N/2)
T=S[:X]+S[:X]
if N%2 !=0:
  print("No")
elif S==T:
  print("Yes")
else:
  print("No")
print(f"Christmas {' '.join(['Eve'] * (25 - int(input())))}".strip())


### FIXED CODE ###

print("Christmas {}".format(" ".join(['Eve'] * (25 - int(input())))).strip())
import heapq

N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]
ans = 0
A = []

L = sorted(L, key=lambda x: x[1],reverse=True)
L = sorted(L, key=lambda x: x[0],reverse=True)

minv = float("inf")
cnt = 0

for i in range(N) :
    if i >= 1 and L[i][0] != L[i-1][0] :
        cnt = 0
    
    if (M-L[i][0]+1)-cnt <= 0 :
        continue
    if i < M :
        heapq.heappush(A,L[i][1])
        cnt += 1
    else :
        minv = heapq.heappop(A)
        heapq.heappush(A,max(L[i][1], minv))
        cnt += 1

print(sum(A))


### FIXED CODE ###

import heapq

N, M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

D = {}
for i in range(N) :
    k,v = L[i]
    if k not in D :
        D[k] = [v]
    else :
        D[k].append(v)

class Heapq :
    def __init__(self, arr, desc=False) :
        if desc :
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)
    
    def pop(self) :
        return heapq.heappop(self.hq) * self.sign
    
    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)
 
    def top(self):
        return self.hq[0] * self.sign
 
    def size(self):
        return len(self.hq)

q = Heapq([], True)
ans = 0
for k in range(1, M+1) :
    if k in D :
        for v in D[k] :
            q.push(v)
    if q.size() :
        ans += q.pop()
print(ans)
n=int(input())
from math import gcd
from collections import defaultdict
abd=defaultdict(int)
ab=[]
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
        continue
    elif a==0 and b!=0:
        azero+=1
        continue
    elif a!=0 and b==0:
        bzero+=1
        continue
    x=gcd(a,b)
    a//=x
    b//=x
    ab.append((a,b))
    abd[(a,b)]+=1

n-=(wzero+azero+bzero)
kumid=defaultdict(int)
for i in range(n):
    a,b=ab[i]
    cnt=abd[(-b,a)]+abd[(b,-a)]
    kumid[cnt]+=1
maxkey=max(kumid.keys())
ans=1

for i in range(maxkey,1,-1):
    if kumid[i]!=0:
        j=kumid[i]
        kumid[j]-=i
        tmp=2**i+2**j-1
        ans*=tmp
#print(kumid)
ans*=(kumid[1]+1)

ans*=2**kumid[0]
ans*=(2**azero+2**bzero-1)
ans+=wzero
ans-=1
print(ans)

### FIXED CODE ###

from math import gcd
from collections import defaultdict

n=int(input())
abd=defaultdict(int)
mod=10**9+7
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
    elif a==0 and b!=0:
        azero+=1
    elif a!=0 and b==0:
        bzero+=1
    else:
        g=gcd(a,b)
        a=a//g
        b=b//g
        abd[(a,b)]+=1

liskey=list(abd.keys())
ans=1
for k in liskey:
    if abd[k] != 0:
        a,b=k
        x=abd[(a,b)]+abd[(-a,-b)]
        y=abd[(-b,a)]+abd[(b,-a)]
        abd[(a,b)]=0
        abd[(-a,-b)]=0
        abd[(-b,a)]=0
        abd[(b,-a)]=0
        ans*=(2**x+2**y-1+mod)%mod
        ans%=mod

ans*=(2**azero+2**bzero-1)
ans%=mod
ans=(ans+wzero)%mod
ans=(ans+mod-1)%mod
print(ans)
A = list(map(int, input().split()))
K = 0
K = K+A[1]
if A[0]%2==0 and A[3]%2==0 and A[4]%2==0:
	K = K+A[0]+A[3]+A[4]
elif A[0]%2!=0 and A[3]%2!=0 and A[4]%2!=0:
	K = K+A[0]+A[3]+A[4]
elif A[0]+A[3]+A[4]<=2:
	pass
else:
	K = K+A[0]+A[3]+A[4]-1
print(K)


### FIXED CODE ###

x, y = map(int, input().split())
if x==0 and y==0:
	print(0)
elif x>=0 and y==0:
	print(x+1)
elif x>=0 and y>=0:
	if x<=y:
		print(y-x)
	if x>y:
		print(x-y+2)
elif x>=0 and y<0:
	print(abs(x+y)+1)
elif x<0 and y==0:
	print(abs(x))
elif x<0 and y>=0:
	print(abs(x+y)+1)
elif x<0 and y<0:
	if x<=y:
		print(y-x)
	if x>y:
		print(x-y+2)
n,m = map(int,input().split())
a = list(map(int,input()))
A = 0
for i in range(m):
  A += a[i]
if(A<=N):
  print(N-A)
else:
  print(-1)

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
A = 0
for i in range(m):
  A += a[i]
k = n-A
if(k>=0):
  print(k)
else:
  print(-1)
a, b = map(int, input().split)
if a < b:
 print("a < b")
elif a > b:
 print("a > b")
else:
 print("a == b")

### FIXED CODE ###

a, b = map(int, input().split())
if a < b:
 print("a < b")
elif a > b:
 print("a > b")
else:
 print("a == b")
X=int(input())
i=0
while True:
    x1=(X+i**5)**(1/5)
    x2=(X-i**5)**(1/5)
    if x1==int(x1):
        print(int(x1),i)
        exit()
    elif x2==int(x2):
        print(int(x2),-i)
        exit()
    i+=1

### FIXED CODE ###

X=int(input())
J=1000
N=[0]*J
for i in range(0,J):
    N[i]=i**5
for i in range(0,J):
    for j in range(0,J):
        if abs(N[i]-N[j])==X:
            print(int(max(N[i],N[j])**(1/5)),int(min(N[i],N[j])**(1/5)))
            exit()
        elif N[i]+N[j]==X:
            print(int(N[i]**(1/5)),int(-1*N[j]**(1/5)))
            exit()
from collections import defaultdict
MOD = 10**9+7
N, K = map(int, input().split())
es = defaultdict(list)

for i in range(N-1):
  a, b = map(int, input().split())
  es[a-1] += [b-1]
  es[b-1] += [a-1]
  
def dfs(now, par):
  if par==-1:
    can_use = K-1
  else:
    can_use = K-2
  if K<len(es[now]):
    return 0
  else:
    case_num = 1
    for e in es[now]:
      if e==par:
        continue
      case_num *= can_use
      can_use -= 1
      case_num %= MOD
    for e in es[now]:
      if e==par:
        continue
      case_num *= dfs(e, now)
      case_num %= MOD
    return case_num

ans = K*dfs(a-1,-1)
ans %= MOD
print(ans)

### FIXED CODE ###

from collections import defaultdict, deque
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
dic = defaultdict(list)
for i in range(N-1):
  a, b = map(int, input().split())
  dic[a-1] += [b-1]
  dic[b-1] += [a-1]

log = [float('inf')]*N
log[0] = 0
q = deque([0])
ans = K
while q:
  p = q.popleft()
  if log[p]<1:
    ans *= cmb(K-1,K-1-len(dic[p]),mod)
  else:
    ans *= cmb(K-2,K-1-len(dic[p]),mod)
  ans %= mod
  for e in dic[p]:
    if log[e]>log[p]+1:
      q += [e]
      log[e] = log[p]+1
print(ans)
N,A,B = map(int,input().split())
H = sorted([int(input()) for _ in range(N)])
d = A-B
high = H[-1]//B
low = 1
while high-low>1:
    mid = (high+low)//2
    cnt = 0
    for i in range(N):
        cnt += (H[i]-B*mid)//d
    if cnt<=K:
        high = mid
    else:
        low = mid
print(high)

### FIXED CODE ###

import math
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]
low = sum(H)//((N-1)*B+A)-1
high = max(H)//B+1
while high-low>1:
    mid = (high+low)//2
    cnt = 0
    for i in range(N):
        cnt += math.ceil(max(H[i]-mid*B,0)/(A-B))
    if cnt<=mid:
        high = mid
    else:
        low = mid
print(high)
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
i,j = 0,0
start = []
while i<=n-m:
    if b[0] in a[i]:
        start.append(a[i].index(b[0]))
        j += 1
        for k in range(1,m):
            if b[k] in a[i+j]:
                start.append(a[i+j].index(b[k]))
                j += 1
            else:
                start.clear()
                j = 0
                break
            if not start[0] == start[j-1]:
                start.clear()
                j = 0
                break
    if len(start)==m:
        break
    i += 1
print('Yes' if len(start)>0 else 'No')


### FIXED CODE ###

n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
res = True
for i in range(len(b)):
    if b[i] not in a[i]:
        res = False
        break

print('Yes' if res else 'No')
n, k = map(int, input().split())
a = set()

for _ in range(k):
  d = int(input())
  while m <= d:
    l = int(input())
    a.append(l)
    m += 1

print(n - len(a))


### FIXED CODE ###

n, k = map(int, input().split())
a = []

for _ in range(k):
  d = int(input())
  a += [int(m) for m in input().split()]

print(n - len(set(a)))
from collections import deque
n,q=map(int,input().split())
L=[[]for _ in range(n)]
V=[False]*n
P=[0]*n
for i in range(n-1):
   a,b=map(int,input().split())
   L[a-1].append(b-1)
   L[b-1].append(a-1)
for i in range(q):
   p,x=map(int,input().split())
   P[p-1]+=x
que=deque([0])
while que:
   s=que.popleft()
   V[s]=True
      for ni in L[s]:
         if V[ni]==False:
            P[ni]+=P[s]
            que.append(ni)
print(*P)

### FIXED CODE ###

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
PX = [list(map(int, input().split())) for _ in range(Q)]
 
graph = [[] for _ in range(N + 1)]
for a, b in AB:
  graph[a].append(b)
  graph[b].append(a)
  
cost = [0] * (N + 1)
for p, x in PX:
  cost[p] += x
  
check = [0] * (N + 1)
stack = [1]
check[1] = 1
 
while stack:
  s = stack.pop()
  for g in graph[s]:
    if check[g] == 0:
      check[g] = 1
      cost[g] += cost[s]
      stack.append(g)
      
print(*cost[1:])
# ABC138D - Ki
# https://atcoder.jp/contests/abc138/submissions/7012991
import sys
input = sys.stdin.readline

class Node:
    def __init__(self, parent=None):
        self.val = 0
        self.parent = parent


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [Node() for _ in range(N)]  # tree
    for a, b in A:  # set tree relationships
        T[b - 1].parent = a - 1
    for p, x in P:  # increment on roots
        T[p - 1].val += x
    for i in range(1, N):  # increment to children
        j = T[i].parent
        T[i].val += T[j].val
    print(*[node.val for node in T])


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC138D - Ki
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # T[i] := children of vertex i
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()
A,B = map(int, input().split())
if A != 1 and B != 1:
	if A > B:
  	  print("Alice")
	elif B > A:
  	  print("Bob")
	elif A == B:
      print("Draw")
else:
  if A == 1:
    print("Alice")
  else:
   	print("Bob")

### FIXED CODE ###

A, B = map(int, input().split())
if A != 1 and B != 1 and A > B:
  	print("Alice")
elif  A != 1 and B != 1 and B > A:
    print("Bob")
elif A == B:
    print("Draw")
elif A == 1:
    print("Alice")
else:
    print("Bob")
import sys
def order (p):
    return (sorted(p))         
def Mix_Juice (p):
    p[0] = len (p)
    p[1] = K
    a = order (p[2:p[0]])
    b = 0
    for i in range (0, K-1):
        b = b + a[i]
    return b
p = list(map(int, input().split()))
Mix_Juice (p)

### FIXED CODE ###

n = input()
m = n.split()

a = [input() for l in range(0,1)]
b = a[0].split()


for i in range(0, len(b)):
    b[i] = int(b[i])

c = sorted(b, reverse=True)

p = 0
for i in range(int(m[0]) - int(m[1]),int(m[0])):
    p = p + int(c[i])
print(int(p))
def time(h):
    if h == 1:
        return 1
    else:
        return time(h//2)*2 + 1

print(time(H))

### FIXED CODE ###

H = int(input())

def time(h):
    if h == 1:
        return 1
    elif h > 1:
        return time(h//2)*2 + 1

print(time(H))
n=int(input())
a=int(input())
print(Nn**2-a)

### FIXED CODE ###

n=int(input())
a=int(input())
print(n**2-a)
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

import numpy as np

L, R = map(int, input().split())
if (L - R) > 2020:
    print(0)
    exit()
else:
    k = np.arange(L, R + 1, dtype=np.int64)
    k = k % 2019
    k = sorted(k)
    print(k[0] * k[1])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

L, R = map(int, input().split())
if (R - L) > 3000:
    print(0)
    exit()
else:
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)
n, m = map(int, input().split())

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = map(int, input().split())

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    for s in d:
      count += switch_states[s-1]
      if count % 2 == P[di]:
        ans += 1
        
        
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = list(map(int, input().split()))

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    
    for s in d:
      count += switch_states[s-1]
      
    if count % 2 != P[di]:
      ans -= 1
      break

  ans += 1
        
        
print(ans)
N=input()
if N%2==0:
  print(N/2)
else:
  print(int(N/2))

### FIXED CODE ###

N=int(input())
if N%2==0:
    print(1/2)
else:
     print(((N + 1)/2)/N)
N, L = map(int, input().split())
S = []
for i in rangeN):
    S.append(input())
print(('').join(sorted(S)))


### FIXED CODE ###

#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
N, L = map(int, input().split())
S = []
for i in range(N):
    S.append(input())
print(('').join(sorted(S)))
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))

### FIXED CODE ###

s = input()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")
import sys
from collections import defaultdict

stairs = []
steps = []
MOD = 1000000007

n, m = int(input()), int((input()))
stairs = {int(input()):True for i in range(m)}

step = defaultdict(int)
step[0] = 1

for i in range(n):
    if i in stairs.keys():
        step[i] = 0
    else:
        step[i+1] = (step[i] + step[i+1]) % MOD
        step[i+2] = (step[i] + step[i+2]) % MOD

print(step[n])


### FIXED CODE ###

from collections import defaultdict

stairs = []
steps = []
MOD = 1000000007

n, m = map(int, input().split())
stairs = {int(input()):True for _ in range(m)}

step = defaultdict(int)
step[0] = 1

for i in range(n):
    if i in stairs.keys():
        step[i] = 0
    else:
        step[i+1] = (step[i] + step[i+1]) % MOD
        step[i+2] = (step[i] + step[i+2]) % MOD

print(step[n])
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(readline())
xl = [list(map(int, readline().decode('utf-8').split())) for _ in range(n)]
xl = np.array(xl)
xl_ = np.c_[xl[:, 0] - xl[:, 1], xl[:, 0] + xl[:, 1]]
xl_ += abs(xl_.min()) + 1

cnt_array = np.zeros(xl_.max())
cnt = 0
for l, r in xl_:
    if (cnt_array[l:r] > 0).sum() > 0:
        continue
    else:
        cnt_array[l:r] += 1
        cnt += 1

cnt_ = 0
for l, r in xl_[::-1]:
    if (cnt_array[l:r] > 0).sum() > 0:
        continue
    else:
        cnt_array[l:r] += 1
        cnt_ += 1

print(max(cnt, cnt_))


### FIXED CODE ###

import sys
from operator import itemgetter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(readline())
xl = [list(map(int, readline().decode('utf-8').split())) for _ in range(n)]
LR = [(x - l, x + l) for x, l in xl]
LR.sort(key=itemgetter(1))

acc = -10**18

cnt = 0

for l, r in LR:
    if acc > l:
        continue
    cnt += 1
    acc = r

print(cnt)