TnT/CodeNet4Repair huggingface dataset:
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = int(input())


x = N % 500

if x >= A:
	print("Yes")
else:
	print("No")

Fixed, accepted submission:
N = int(input())
A = int(input())

num = N % 500

if num <= A:
  print("Yes")
else:
  print("No")
Problem:
Snuke has N hats. The i-th hat has an integer a_i written on it.  There are N camels standing in a circle. Snuke will put one of his hats on each of these camels.  If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`.    * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.  What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.

Incorrect submission (verdict: Wrong Answer):
from collections import Counter

n=int(input())
a=list(map(int, input().split()))

flag="No"

count_by_kw = Counter()
for i in range(n):
    count_by_kw[a[i]]+=1

print(count_by_kw)

if count_by_kw.get(0) == n:
    flag="Yes"

if count_by_kw.get(0) == n/3 and len(count_by_kw.keys())==2:
    flag="Yes"
    
if len(count_by_kw.values()) == 3:
    if count_by_kw.get(0) == count_by_kw.get(1) and count_by_kw.get(0) == count_by_kw.get(2):
        flag="Yes"
    
print(flag)





Fixed, accepted submission:
from collections import Counter

n=int(input())
a=list(map(int, input().split()))

flag="No"

count_by_kw = Counter()
for i in range(n):
    count_by_kw[a[i]]+=1

if count_by_kw.get(0) == n:
    flag="Yes"

if count_by_kw.get(0) == n/3 and len(count_by_kw.keys())==2:
    flag="Yes"

cl=list(count_by_kw.values())
ck=list(count_by_kw.keys())

if len(cl)==3:
    if cl[0] == cl[1] and cl[1] == cl[2]:
        xor = ck[0]^ck[1]^ck[2]
        if xor == 0:
            flag="Yes"
        
print(flag)
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
a=int(input())
b=int(input())
if int(b/100)%5==0:
  if b%500<=a:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Fixed, accepted submission:
a=int(input())
b=int(input())
if a%500<=b:
  print("Yes")
else:
  print("No")
Problem:
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.  Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N.  Find the minimum cost incurred before reaching the goal.

Incorrect submission (verdict: Wrong Answer):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
print(a)
print(min((len([i for i in a if i<x])),(len([i for i in a if i>x]))))

Fixed, accepted submission:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
print(min((len([i for i in a if i<x])),(len([i for i in a if i>x]))))
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int,input().split())
print(a,b)
x = a*b
y = 2 * (a + b)
print(x,y)


Fixed, accepted submission:
a, b = map(int,input().split())
x = a*b
y = 2 * (a + b)
print(x,y)
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
print(n%1000)

Fixed, accepted submission:
n = int(input())
if n%1000 == 0:
    print(0)
else:
    print(1000-n%1000)
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
# ABC048
a, b, x = map(int, input().split())

print(a//x+b//x + (a % x == 0))


Fixed, accepted submission:
# ABC048
a, b, x = map(int, input().split())

print(b//x - a//x + (a % x == 0))
Problem:
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.  How many squares i satisfy both of the following conditions?    * The assigned number, i, is odd.   * The written integer is odd.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))

# L, R, d = map(int, input().split())
cnt = 0
for i in range(0, N, 2):
    print(i)
    if a[i] % 2 != 0:
        cnt += 1
print(cnt)
        


Fixed, accepted submission:
N = int(input())
a = list(map(int, input().split()))

# L, R, d = map(int, input().split())
cnt = 0
for i in range(0, N, 2):

    if a[i] % 2 != 0:
        cnt += 1
print(cnt)
Problem:
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 27 19:18:58 2018
tenka1C
@author: maezawa
"""

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a.sort()
b=a[::-1]
pos = n//2
res = 0
c = [-1]*n
sign = -1
for i in range(n):
    print(pos, i)
    if i%2 == 0:
        c[pos]=a[i]
        pos += sign*(i+1)
        if pos<0 or pos>=n:
            break
        c[pos]=b[i]
        pos = pos - sign*(i+2)
        if pos<0 or pos>=n:
            break
    else:
        c[pos]=b[i]
        pos += sign*(i+2)
        if pos<0 or pos>=n:
            break
        c[pos]=a[i]
        pos = pos - sign*(i+3)
        if pos<0 or pos>=n:
            break
        sign *= -1
                    
cnt = 0
for i in range(n-1):
    cnt += abs(c[i]-c[i+1])
print(cnt)

    
    

Fixed, accepted submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 27 19:18:58 2018
tenka1C
@author: maezawa
"""

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a.sort()
b = [2*(-1)**i for i in range(n)]
b[0] = b[0]//2
b[-1] = b[-1]//2
b.sort()
ans1 = sum([a[i]*b[i] for i in range(n)])
c = [-b[i] for i in range(n)]
c.sort()
ans2 = sum([a[i]*c[i] for i in range(n)])
                    
print(max([ans1,ans2]))
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = int(input())
print('YES' if n % 500 <= a else 'NO')

Fixed, accepted submission:
n = int(input())
a = int(input())
print('Yes' if n % 500 <= a else 'No')
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
c=a-b

if a <= b:
    print(c+1)
else:
    print(c)

Fixed, accepted submission:
a,b=map(int,input().split())
c=a-1

if a <= b:
    print(c+1)
else:
    print(c)
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
hoge=[]
for i in range(n):
  hoge.append(input())
m=int(input())
huga=[]
for i in range(m):
  huga.append(input())
ans=0
while 1:
  blue=hoge.count(hoge[0])
  red=huga.count(hoge[0])
  if(blue>red):
    ans+=blue-red
  hoge.remove(hoge[0])
  if(len(hoge)==0):
    break
    
print(ans)

Fixed, accepted submission:
n=int(input())
hoge=[]
for i in range(n):
  hoge.append(input())
m=int(input())
huga=[]
for i in range(m):
  huga.append(input())
ans=[]
ans.append(0)
for i in range(len(hoge)):
  ans.append(hoge.count(hoge[i])-huga.count(hoge[i]))

print(max(ans))
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
# coding: utf-8
A, B, C = map(int, input().split())
print(any(A*i%B==C for i in range(1,B+1)) and "Yes" or "NO")

Fixed, accepted submission:
# coding: utf-8
A, B, C = map(int, input().split())
ans ="NO"
for i in range(1,B+1):
    if (A*i)%B==C:
        ans= "YES"
print(ans)
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
s=""
if tx!=sx and ty!=sy:
  
  s+="R"*x
  s+="U"*y
  s+="D"*y
  s+="L"*x
  
  s+="L"
  s+="U"*(y+1)
  s+="R"*(x+1)
  s+="R"
  s+="D"*(y+1)
  s+="L"*(x+1)
elif tx==sx:
  s+="R"*x
  s+="D"+"L"*x+"U"
  s+="U"+"R"*x+"D"
  s+="R"
  s+="U"*2
  s+="L"*(x+2)
  s+="D"*2
  s+="R"
elif ty==sy:
  s+="U"*x
  s+="R"+"D"*x+"L"
  s+="L"+"U"*x+"R"
  s+="U"
  s+="R"*2
  s+="D"*(y+2)
  s+="L"*2
  s+="U"
print(s)
  

Fixed, accepted submission:
sx,sy,tx,ty=map(int,input().split())
ans=""
ans+="U"*(ty-sy)
ans+="R"*(tx-sx)
ans+="D"*(ty-sy)
ans+="L"*(tx-sx)
ans+="L"
ans+="U"*(ty-sy+1)
ans+="R"*(tx-sx+1)
ans+="D"
ans+="R"
ans+="D"*(ty-sy+1)
ans+="L"*(tx-sx+1)
ans+="U"
print(ans)
Problem:
You are parking at a parking lot. You can choose from the following two fee plans:    * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.   * Plan 2: The fee will be B yen, regardless of the duration.  Find the minimum fee when you park for N hours.

Incorrect submission (verdict: Wrong Answer):
n,a,b = map(int, input().split())

if n * a > b:
    print (n*a)
else:
    print (b)

Fixed, accepted submission:
n,a,b = map(int, input().split())

if n * a < b:
    print (n*a)
else:
    print (b)
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
n = int(input())  
str_list = [input() for _ in range(n)]
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(n):
  if str_list[i] == 'AC':
    AC +=1
  elif str_list[i] == 'WA':
    WA += 1
  elif str_list == 'TLE':
    TLE += 1
  elif str_list == 'RE':
    RE += 1
print('AC ×', AC)
print('WA ×', WA)
print('TLE ×', TLE)
print('RE ×', RE)

Fixed, accepted submission:
n = int(input())  
str_list = [input() for _ in range(n)]
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(n):
  if str_list[i] == 'AC':
    AC +=1
  elif str_list[i] == 'WA':
    WA += 1
  elif str_list[i] == 'TLE':
    TLE += 1
  elif str_list[i] == 'RE':
    RE += 1
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def insersion_sort(A, N):
    for i in range(1, N):
      for k in A:
        if k==len(A):
          print(k)
        else:
          print(k, " ", sep="", end="")
      v = A[i]
      j = i-1
      while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
      A[j+1] = v
    for k in A:
      if k==len(A):
        print(k)
      else:
        print(k, " ", sep="", end="")

N = int(input())
A = list(map(int, input().split()))
Algo.insersion_sort(A, N)

Fixed, accepted submission:
#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def insersion_sort(A, N):
    for i in range(1, N):
      for k in A:
        if k==A[len(A)-1]:
          print(k)
        else:
          print(k, " ", sep="", end="")
      v = A[i]
      j = i-1
      while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
      A[j+1] = v
    for k in A:
      if k==A[len(A)-1]:
        print(k)
      else:
        print(k, " ", sep="", end="")

N = int(input())
A = list(map(int, input().split()))
Algo.insersion_sort(A, N)
Problem:
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i.  Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==0:
  for i in range(n):
    if a[i]!=i//2+1:
      print(0)
      exit()
  print(2**(n//2))
else:
  for i in range(n):
    if a[i]!=i//2+2:
      print(0)
      exit()
  print(2**(n//2))

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
if n%2==0:
  for i in range(n):
    if a[i]!=(i//2)*2+1:
      print(0)
      exit()
  print(pow(2,n//2,mod))
else:
  for i in range(n):
    if a[i]!=((i+1)//2)*2:
      print(0)
      exit()
  print(pow(2,n//2,mod))
Problem:
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.

Incorrect submission (verdict: Wrong Answer):
s=input()
a,b=0,0
for i in range(len(s)):
  if s[i]=='A':
    a=i
    break
for j in range(len(s)-1,-1):
  if s[j]=='Z':
    b=j
    break
print(len(s[a:b+1]))

Fixed, accepted submission:
s=input()
a,b=0,0
for i in range(len(s)):
  if s[i]=='A':
    a=i
    break
for j in range(len(s)-1,-1,-1):
  if s[j]=='Z':
    b=j
    break
print(len(s[a:b+1]))
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

num = 0
while True:
    s = sys.stdin.readline().strip()
    if s == '0':
        break
    num += 1
    print('Case: ', num, ' ', s, sep='')



Fixed, accepted submission:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

num = 0
while True:
    s = sys.stdin.readline().strip()
    if s == '0':
        break
    num += 1
    print('Case ', num, ': ', s, sep='')
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
change = n % 1000
print(change)

Fixed, accepted submission:
n = int(input())
change = n % 1000
if change != 0:
  print(1000 - change)
else:
  print(0)
Problem:
N persons are standing in a row. The height of the i-th person from the front is A_i.  We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:  Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.  Find the minimum total height of the stools needed to meet this goal.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = map(int, input().split())

#current height
now = 0
total = 0

for a in A:
    print("a", a)

    if a >= now:
        now = a
        pass
    else:
        total += now - a
    #print("now", now)
    

print(total)


Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))

#current height
now = 0
total = 0

for a in A:
    if a >= now:
        now = a
        pass
    else:
        total += now - a

print(total)
Problem:
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".

Incorrect submission (verdict: Wrong Answer):
a,b,c =[int(i) for i in input().split()]

if(a < b and b < c):
	print("YES")
else:
	print("NO")

Fixed, accepted submission:
a,b,c =[int(i) for i in input().split()]

if(a < b and b < c):
	print("Yes")
else:
	print("No")
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int, input().format())
print("a + b + c")

Fixed, accepted submission:
a  = input()
b = str(a)
c = 0
for n in b:
    if n == str(1):
        c += 1
print(c)
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
B = list(map(int, input().split()))

ans = [0]*N
for i in range(N, 0, -1):
    print(i)
    cnt = 0
    j = 1
    while i*j<=N:
        cnt += ans[i*j-1]
        j += 1
    if cnt%2 != B[i-1]:
        ans[i-1] = 1

if sum(ans)>= 1:
    print(sum(ans))

    A =[]
    for i, j in enumerate(ans, 1):
        if j == 1:
            A.append(i)

    print(*A)

else:
    print(-1)

Fixed, accepted submission:
N = int(input())
B = list(map(int, input().split()))

ans = [0]*N
for i in range(N, 0, -1):
    cnt = 0
    j = 1
    while i*j<=N:
        cnt += ans[i*j-1]
        j += 1
    if cnt%2 != B[i-1]:
        ans[i-1] = 1

print(sum(ans))

A =[]
for i, j in enumerate(ans, 1):
    if j == 1:
        A.append(i)

print(*A)
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Incorrect submission (verdict: Wrong Answer):
temp = input()
a,b,c = temp.split()
a = int(a)
b = int(b)
c = int(c)
inp = [a,b,c]
inp = sorted(inp)
print(inp)
dif = inp[2] - inp[0] + inp[2] - inp[1]
if dif%2 == 0:
    print(dif//2)
else:
    print((dif+3)//2)


Fixed, accepted submission:
temp = input()
a,b,c = temp.split()
a = int(a)
b = int(b)
c = int(c)
inp = [a,b,c]
inp = sorted(inp)
dif = inp[2] - inp[0] + inp[2] - inp[1]

if dif%2 == 0:
    print(dif//2)
else:
    print((dif+3)//2)
Problem:
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.  We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.  Find the maximum number of robots that we can keep.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
X = []
for i in range(n):
  x,l = map(int,input().split())
  ll = x-l
  rr = x+l
  X.append((x,l,ll,rr))

if n == 1:
  print(n)
else:
  XL = sorted(X, key=lambda x: x[0])

  wkans = 0
  idx = 0
  m = 1

  while idx+m < n:
    if XL[idx][3] < XL[idx+m][2]:
      idx += m
      m = 1
      # if idx+m > n-1:
      #   break
    else:
      if XL[idx][1] < XL[idx+m][1]:
        m += 1
        wkans += 1
        # if idx+m > n-1:
        #   break
      else:
        idx += m
        m = 1
        wkans += 1
        # if idx+m > n-1:
        #   break

  print(n-wkans)




# 1 10  -9 11
# 8 20 -12 28





Fixed, accepted submission:
n = int(input())
X = []
for i in range(n):
  x,l = map(int,input().split())
  ll = x-l
  rr = x+l
  X.append((x,l,ll,rr))

if n == 1:
  print(n)
else:
  XL = sorted(X, key=lambda x: x[3])

  # print(XL)

  ans = 0
  temp = -1 * (10**9)

  for i in range(n):
    if temp <= XL[i][2]:
      ans += 1
      temp = XL[i][3]

  print(ans)