Ashish has an array $$$a$$$ of consisting of $$$2n$$$ positive integers. He wants to compress $$$a$$$ into an array $$$b$$$ of size $$$n-1$$$. To do this, he first discards exactly $$$2$$$ (any two) elements from $$$a$$$. He then performs the following operation until there are no elements left in $$$a$$$:   Remove any two elements from $$$a$$$ and append their sum to $$$b$$$. The compressed array $$$b$$$ has to have a special property. The greatest common divisor ($$$\mathrm{gcd}$$$) of all its elements should be greater than $$$1$$$.Recall that the $$$\mathrm{gcd}$$$ of an array of positive integers is the biggest integer that is a divisor of all integers in the array.It can be proven that it is always possible to compress array $$$a$$$ into an array $$$b$$$ of size $$$n-1$$$ such that $$$gcd(b_1, b_2..., b_{n-1}) > 1$$$. Help Ashish find a way to do so.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$2 \leq n \leq 1000$$$). The second line of each test case contains $$$2n$$$ integers $$$a_1, a_2, \ldots, a_{2n}$$$ ($$$1 \leq a_i \leq 1000$$$) — the elements of the array $$$a$$$.

For each test case, output $$$n-1$$$ lines — the operations performed to compress the array $$$a$$$ to the array $$$b$$$. The initial discard of the two elements is not an operation, you don't need to output anything about it. The $$$i$$$-th line should contain two integers, the indices ($$$1$$$ —based) of the two elements from the array $$$a$$$ that are used in the $$$i$$$-th operation. All $$$2n-2$$$ indices should be distinct integers from $$$1$$$ to $$$2n$$$. You don't need to output two initially discarded elements from $$$a$$$. If there are multiple answers, you can find any.

package main

import (
  . "fmt"
)

var t int
func main() {
  Scan(&t)
  for tc := 0; tc < t; tc++ {
    var n int
    var a int
    evens := make([]int, n)
    odds := make([]int, n)
    Scan(&n)
    for i := 0; i < 2*n; i++ {
      Scan(&a)
      if a % 2 == 1 {
        odds = append(odds, i+1)
      } else {
        evens = append(evens, i+1)
      }
    }
    pos1,pos2 := 0,0
    if len(odds) % 2 == 1 {
      pos1++
      pos2++
    } else if len(evens) == 2*n {
      pos2+=2
    } else {
      pos1+=2
    }
    for i := pos1; i < len(odds); i += 2 {
      Println(odds[i], odds[i+1])
    }
    for i := pos2; i < len(evens); i += 2 {
      Println(evens[i], evens[i+1])
    }
  }
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"sort"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, 2*n)
		res := solve(n, A)
		var buf bytes.Buffer

		for _, ans := range res {
			buf.WriteString(fmt.Sprintf("%d %d\n", ans[0], ans[1]))
		}

		fmt.Println(buf.String())
	}
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}
func solve(n int, A []int) [][]int {
	ps := make([]Pair, 2*n)
	for i := 0; i < len(A); i++ {
		ps[i] = Pair{A[i], i}
	}
	sort.Sort(Pairs(ps))

	j := sort.Search(len(ps), func(j int) bool {
		return ps[j].first&1 == 0
	})

	if j&1 == 1 {
		j--
	}
	var p int
	res := make([][]int, n-1)
	for i := 0; i < j && p < n-1; i += 2 {
		res[p] = []int{ps[i].second + 1, ps[i+1].second + 1}
		p++
	}

	for i := len(ps) - 1; p < n-1; i -= 2 {
		res[p] = []int{ps[i-1].second + 1, ps[i].second + 1}
		p++
	}
	return res
}

type Pair struct {
	first, second int
}

type Pairs []Pair

func (pairs Pairs) Len() int {
	return len(pairs)
}

func (pairs Pairs) Less(i, j int) bool {
	a := pairs[i]
	b := pairs[j]

	return a.first&1 > b.first&1 || a.first&1 == b.first&1 && a.second < b.second
}

func (pairs Pairs) Swap(i, j int) {
	pairs[i], pairs[j] = pairs[j], pairs[i]
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"sort"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, 2*n)
		res := solve(n, A)
		var buf bytes.Buffer

		for _, ans := range res {
			buf.WriteString(fmt.Sprintf("%d %d\n", ans[0], ans[1]))
		}

		fmt.Println(buf.String())
	}
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}
func solve(n int, A []int) [][]int {
	ps := make([]Pair, 2*n)
	for i := 0; i < len(A); i++ {
		ps[i] = Pair{A[i], i}
	}
	sort.Sort(Pairs(ps))

	j := sort.Search(len(ps), func(j int) bool {
		return ps[j].first&1 == 0
	})
	var u int
	if j&1 == 1 {
		u++
	}
	var p int
	res := make([][]int, n-1)

	for p < n-1 {
		res[p] = []int{ps[u].second + 1, ps[u+1].second + 1}
		u += 2
		p++
	}

	return res
}

type Pair struct {
	first, second int
}

type Pairs []Pair

func (pairs Pairs) Len() int {
	return len(pairs)
}

func (pairs Pairs) Less(i, j int) bool {
	a := pairs[i]
	b := pairs[j]

	return a.first&1 > b.first&1 || a.first&1 == b.first&1 && a.second < b.second
}

func (pairs Pairs) Swap(i, j int) {
	pairs[i], pairs[j] = pairs[j], pairs[i]
}

// https://codeforces.com/contest/1365/problem/A
package main

import (
	"bufio"
	"fmt"
	"os"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

type my struct {
	val, index int
}
func solver() {
	var n int
	fmt.Fscan(input, &n)
	even, odd := make([]my, 0), make([]my, 0)
	for i := 0; i < 2*n; i++ {
		var t int
		fmt.Fscan(input, &t)
		if t & 1 == 1 {
			odd = append(odd, my{t, i + 1})
		} else {
			even = append(even, my{t, i + 1})
		}
	}
	e, o := 0, 0
	n--
	for n > 0 && e + 1 < len(even) {
		fmt.Println(even[e].index, even[e+1].index)
		e += 2
		n--
	}
	for n > 0 && o + 1 < len(odd) {
		fmt.Println(odd[o].index, odd[o+1].index)
		o += 2
		n--
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, 1024*1024)
	scanner.Split(bufio.ScanWords)

	input := func() int {
		scanner.Scan()
		i, _ := strconv.Atoi(scanner.Text())
		return i
	}

	var t, n int

	t = input()

	for ; t > 0; t-- {
		n = input()

		arr := make([]int, 2*n)

		for i := range arr {
			arr[i] = input()
		}

		countEven := 0
		countOdd := 0

		for i := range arr {
			if arr[i]%2 == 0 {
				countEven++
			} else {
				countOdd++
			}
		}

		if countOdd == 0 {
			countEven -= 2
		} else if countOdd%2 == 0 {
			countOdd -= 2
		} else {
			countOdd--
			countEven--
		}

		numCollected := 0
		prev := 0

		for i := range arr {
			if countEven > 0 {
				if arr[i]%2 == 0 {
					if numCollected == 0 {
						prev = i
						numCollected++
					} else {
						fmt.Println(prev+1, i+1)
						numCollected = 0
						prev = 0
					}

					countEven--
				}
			} else {
				break
			}
		}

		numCollected = 0
		prev = 0
		for i := range arr {
			if countOdd > 0 {
				if arr[i]%2 == 1 {
					if numCollected == 0 {
						prev = i
						numCollected++
					} else {
						fmt.Println(prev+1, i+1)
						numCollected = 0
						prev = 0
					}

					countOdd--
				}
			} else {
				break
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		evens := make([]int, 2*n)
		odds := make([]int, 2*n)
		evensLen := 0
		oddsLen := 0
		for j := 1; j <= 2*n; j++ {
			var x int
			fmt.Scan(&x)
			if x%2 == 0 {
				evens[evensLen] = j
				evensLen++
			} else {
				odds[oddsLen] = j
				oddsLen++
			}
		}
		if evensLen%2 == 0 && evensLen > 0 {
			evensLen -= 2
		} else if oddsLen%2 == 0 {
			oddsLen -= 2
		}
		// fmt.Println(evensLen, evens)
		// fmt.Println(oddsLen, odds)

		for j := 0; j < evensLen/2; j++ {
			fmt.Println(evens[2*j], evens[2*j+1])
		}
		for j := 0; j < oddsLen/2; j++ {
			fmt.Println(odds[2*j], odds[2*j+1])
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		ns := readLine(reader)
		line := readLine(reader)
		arrs := strings.Split(string(line), " ")
		odds := make([]int, 0)
		evens := make([]int, 0)
		n, _ := strconv.Atoi(string(ns))
		for i := 0; i < 2*n; i++ {
			number, _ := strconv.Atoi(arrs[i])
			if number % 2 == 1 {
				odds = append(odds, i+1)
			} else {
				evens = append(evens, i+1)
			}
		}
		if len(odds) % 2 == 0 && len(odds) > 0 {
			odds = odds[:len(odds)-2]
		} else if len(evens) % 2 == 0 && len(evens) > 0 {
			evens = evens[:len(evens)-2]
		} else if len(odds) % 2 == 1 {
			odds = odds[:len(odds)-1]
			evens = evens[:len(evens)-1]
		}
		for i:=0;i<len(odds);i+=2 {
			fmt.Println(odds[i], odds[i+1])
		}
		for i:=0;i<len(evens);i+=2 {
			fmt.Println(evens[i], evens[i+1])
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	t := ReadInt()
	for i := 0; i < t; i++ {
		n := ReadInt()
		as := ReadInts(2 * n)
		solve(n, as)
	}
}

func solve(n int, as []int) {
	copied := Dup(as)
	sort.Sort(sort.IntSlice(copied))
	maxCombi := copied[len(copied)-1] + copied[len(copied)-2]

	_, primes := Sieve(maxCombi)
	for _, prime := range primes {
		if check(prime, n, as) {
			return
		}
	}
}

func check(div int, n int, as []int) bool {
	ans := [][]int{}
	used := make(map[int]bool)
	for i := 0; i < len(as)-1; i++ {
		if used[i] {
			continue
		}
		for j := i + 1; j < len(as); j++ {
			if used[j] {
				continue
			}
			if (as[i]+as[j])%div == 0 {
				ans = append(ans, []int{i, j})
				used[i] = true
				used[j] = true
				break
			}
		}
	}
	if len(ans) >= n-1 {
		for i := 0; i < n-1; i++ {
			fmt.Println(ans[i][0]+1, ans[i][1]+1)
		}
		return true
	}
	return false
}

func Dup(xs []int) []int {
	return append([]int{}, xs...)
}

// Sieve returns isPrime, primes
func Sieve(max int) ([]bool, []int) {
	isPrime := make([]bool, max+1)
	for i := 2; i <= max; i++ {
		isPrime[i] = true
	}
	primes := []int{}
	for i := 2; i <= max; i++ {
		if !isPrime[i] {
			continue
		}
		for j := 2 * i; j <= max; j += i {
			isPrime[j] = false
		}
		primes = append(primes, i)
	}
	return isPrime, primes
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	a, err := strconv.Atoi(Read())
	if err != nil {
		panic(err)
	}
	return a
}

func ReadInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt()
	}
	return ret
}

func ReadInt64() int64 {
	a, err := strconv.ParseInt(Read(), 10, 64)
	if err != nil {
		panic(err)
	}
	return a
}

func ReadInt64s(n int) []int64 {
	ret := make([]int64, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt64()
	}
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var nTest, n int

type pair struct {
	val int
	id  int
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n)
		odd := []int{}
		even := []int{}
		var x int
		for i := 0; i < n*2; i++ {
			fmt.Fscan(in, &x)

			if x&1 == 0 {
				even = append(even, i+1)
			} else {
				odd = append(odd, i+1)
			}
		}

		nOdd := len(odd) / 2 * 2
		nEven := 2*n - 2 - nOdd
		if nEven < 0 {
			nEven = 0
			nOdd -= 2
		}
		// fmt.Println("AHIHI", nOdd, nEven)
		for i := 0; i < nOdd/2; i++ {
			fmt.Fprintln(out, odd[i*2], odd[i*2+1])
		}
		for i := 0; i < nEven/2; i++ {
			fmt.Fprintln(out, even[i*2], even[i*2+1])
		}
	}

	out.Flush()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1370B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		id := [2][]int{}
		for i := 1; i <= 2*n; i++ {
			Fscan(in, &v)
			id[v&1] = append(id[v&1], i)
		}
		if len(id[0])&1 == 0 {
			if len(id[0]) > 0 {
				id[0] = id[0][2:]
			} else {
				id[1] = id[1][2:]
			}
		} else {
			id[0] = id[0][1:]
			id[1] = id[1][1:]
		}
		for _, v := range id {
			for i := 0; i < len(v); i += 2 {
				Fprintln(out, v[i], v[i+1])
			}
		}
	}
}

func main() { CF1370B(os.Stdin, os.Stdout) }

package main

import (
	"fmt"
	"math"
)

const PI = math.Pi
const mod = 1e9 + 7

func main() {
	//rand.Seed(time.Now().UnixNano())
	var t int
	for fmt.Scan(&t);t>0;t-- {
		var n int
		fmt.Scan(&n)
		var j []int
		var o []int
		for i := 0; i < 2*n; i++ {
			k := 0
			fmt.Scan(&k)
			if k % 2 == 0 {
				o = append(o, i+1)
			}else {
				j = append(j, i+1)
			}
		}
		if len(j)%2 == 0 {
			for i := 2; i < len(j); i+=2 {
				fmt.Println(j[i],j[i+1])
			}
			k := 0
			if len(j) == 0 {
				k = 2
			}
			for i := k; i < len(o); i+=2 {
				fmt.Println(o[i],o[i+1])
			}
		}else{
			for i := 1; i < len(j); i+=2 {
				fmt.Println(j[i],j[i+1])
			}
			for i := 1; i < len(o); i+=2 {
				fmt.Println(o[i],o[i+1])
			}
		}
	}
}

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)
var reader = bufio.NewReader(os.Stdin)

func readInt(delim byte) int {
    text, _ := reader.ReadString(delim)
    n, _ := strconv.ParseInt(strings.TrimSpace(text), 0, 32)
    return int(n)
}

func main() {
    t := readInt('\r')
    for i := 0; i < t; i++ {
        n := readInt('\r')
        lastOdd := -1
        lastEven := -1
        for j := 0; j < 2 * n - 2; j++ {
            curParity := readInt(' ') % 2
            if curParity == 0 {
                if lastEven != -1 {
                    fmt.Println(lastEven, j + 1)
                    lastEven = -1
                } else {
                    lastEven = j + 1
                }
            } else {
                if lastOdd != -1 {
                    fmt.Println(lastOdd, j + 1)
                    lastOdd = -1
                } else {
                    lastOdd = j + 1
                }
            }
        }
        prev := readInt(' ') % 2
        _ = readInt('\r')
        if lastOdd == -1 && lastEven == -1 {
            continue
        }
        if prev == 0 {
            fmt.Println(lastEven, 2*n - 1)
        } else {
            fmt.Println(lastOdd, 2*n - 1)
        }
    }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	t := NextInt()
	for t > 0 {
		t--
		n := NextInt()
		a := make([]int, 2*n)
		for i := 0; i < 2*n; i++ {
			a[i] = NextInt()
		}

		odds := make([]int, 0)
		evens := make([]int, 0)
		for i := 0; i < 2*n; i++ {
			if a[i] % 2 == 0 {
				evens = append(evens, i+1)
			} else {
				odds = append(odds, i+1)
			}
		}

		beginEven := 0
		beginOdd := 0
		if len(evens) % 2 == 0 {
			if len(evens) >= 2 {
				beginEven = 2
				beginOdd = 0
			} else {
				beginEven = 0
				beginOdd = 2
			}
		} else {
			beginEven = 1
			beginOdd = 1
		}

		for i := beginEven; i < len(evens); i += 2 {
			fmt.Println(evens[i], evens[i+1])
		}
		for i := beginOdd; i < len(odds); i += 2 {
			fmt.Println(odds[i], odds[i+1])
		}
	}
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextDouble() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var t, n int
	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)

		odds := make([]int, 0, 1000)
		even := make([]int, 0, 1000)

		var temp int
		for i := 1; i <= 2*n; i++ {
			if i == 2*n {
				fmt.Fscanf(reader, "%d\n", &temp)
			} else {
				fmt.Fscanf(reader, "%d ", &temp)
			}
			if temp%2 == 0 {
				even = append(even, i)
			} else {
				odds = append(odds, i)
			}
		}

		if len(odds)%2 == 1 {
			odds = odds[1:]
		}

		if len(even)%2 == 1 {
			even = even[1:]
		}

		if len(odds)+len(even) == 2*n {
			if len(odds) > 0 {
				odds = odds[2:]
			} else {
				even = even[2:]
			}
		}

		for i := 0; i+1 < len(odds); i += 2 {
			fmt.Printf("%d %d\n", odds[i], odds[i+1])
		}

		for i := 0; i+1 < len(even); i += 2 {
			fmt.Printf("%d %d\n", even[i], even[i+1])
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var T int
	con.Scan(&T)
	for testcase := 0; testcase < T; testcase++ {
		var n int
		con.Scan(&n)
		e := []int{}
		o := []int{}
		for i := 0; i < n+n; i++ {
			var a int
			con.Scan(&a)
			if a%2 == 0 {
				e = append(e, i+1)
			} else {
				o = append(o, i+1)
			}
		}
		if len(e)%2 == 0 && len(o)%2 == 0 {
			if len(e) > 0 {
				e = e[2:]
			} else {
				o = o[2:]
			}
		} else {
			e = e[1:]
			o = o[1:]
		}
		for i := 0; i < len(e)/2; i++ {
			con.Println(e[i*2], e[i*2+1])
		}
		for i := 0; i < len(o)/2; i++ {
			con.Println(o[i*2], o[i*2+1])
		}
	}
	return nil
}

package main

import (
  . "fmt"
)

var t int
func main() {
  Scan(&t)
  for tc := 0; tc < t; tc++ {
    var n int
    var a int
    evens := make([]int, n)
    odds := make([]int, n)
    Scan(&n)
    for i := 0; i < 2*n; i++ {
      Scan(&a)
      if a % 2 == 1 {
        odds = append(odds, a)
      } else {
        evens = append(evens, a)
      }
    }
    pos1,pos2 := 0,0
    if len(odds) % 2 == 1 {
      //Println(odds[0], evens[0])
      pos1++
      pos2++
    } else {
      //Println(odds[0], odds[1])
      pos1+=2
    }
    for i := pos1; i < len(odds); i += 2 {
      Println(odds[i], odds[i+1])
    }
    for i := pos2; i < len(evens); i += 2 {
      Println(evens[i], evens[i+1])
    }
  }
}

package main

import (
  . "fmt"
)

var t int
func main() {
  Scan(&t)
  for tc := 0; tc < t; tc++ {
    var n int
    var a int
    evens := make([]int, n)
    odds := make([]int, n)
    Scan(&n)
    for i := 0; i < 2*n; i++ {
      Scan(&a)
      if a % 2 == 1 {
        odds = append(odds, i+1)
      } else {
        evens = append(evens, i+1)
      }
    }
    pos1,pos2 := 0,0
    if len(odds) % 2 == 1 {
      pos1++
      pos2++
    } else {
      pos1+=2
    }
    for i := pos1; i < len(odds); i += 2 {
      Println(odds[i], odds[i+1])
    }
    for i := pos2; i < len(evens); i += 2 {
      Println(evens[i], evens[i+1])
    }
  }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, 1024*1024)
	scanner.Split(bufio.ScanWords)

	input := func() int {
		scanner.Scan()
		i, _ := strconv.Atoi(scanner.Text())
		return i
	}

	var t, n int

	t = input()

	for ; t > 0; t-- {
		n = input()

		arr := make([]int, 2*n)

		for i := range arr {
			arr[i] = input()
		}

		countEven := 0
		countOdd := 0

		for i := range arr {
			if arr[i]%2 == 0 {
				countEven++
			} else {
				countOdd++
			}
		}

		if countOdd%2 == 0 {
			countOdd -= 2
		} else {
			countOdd--
			countEven--
		}

		numCollected := 0
		prev := 0

		for i := range arr {
			if countEven > 0 {
				if arr[i]%2 == 0 {
					if numCollected == 0 {
						prev = i
						numCollected++
					} else {
						fmt.Println(prev+1, i+1)
						numCollected = 0
						prev = 0
					}

					countEven--
				}
			} else {
				break
			}
		}

		numCollected = 0
		prev = 0
		for i := range arr {
			if countOdd > 0 {
				if arr[i]%2 == 1 {
					if numCollected == 0 {
						prev = i
						numCollected++
					} else {
						fmt.Println(prev+1, i+1)
						numCollected = 0
						prev = 0
					}

					countOdd--
				}
			} else {
				break
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	t := ReadInt()
	for i := 0; i < t; i++ {
		n := ReadInt()
		as := ReadInts(2 * n)
		solve(n, as)
	}
}

func solve(n int, as []int) {
	sort.Sort(sort.IntSlice(as))
	maxCombi := as[len(as)-1] + as[len(as)-2]

	_, primes := Sieve(maxCombi)
	for _, prime := range primes {
		if check(prime, n, as) {
			return
		}
	}
}

func check(div int, n int, as []int) bool {
	ans := [][]int{}
	used := make(map[int]bool)
	for i := 0; i < len(as)-1; i++ {
		if used[i] {
			continue
		}
		for j := i + 1; j < len(as); j++ {
			if used[j] {
				continue
			}
			if (as[i]+as[j])%div == 0 {
				ans = append(ans, []int{i, j})
				used[i] = true
				used[j] = true
				break
			}
		}
	}
	if len(ans) >= n-1 {
		for i := 0; i < n-1; i++ {
			fmt.Println(ans[i][0]+1, ans[i][1]+1)
		}
		return true
	}
	return false
}

// Sieve returns isPrime, primes
func Sieve(max int) ([]bool, []int) {
	isPrime := make([]bool, max+1)
	for i := 2; i <= max; i++ {
		isPrime[i] = true
	}
	primes := []int{}
	for i := 2; i <= max; i++ {
		if !isPrime[i] {
			continue
		}
		for j := 2 * i; j <= max; j += i {
			isPrime[j] = false
		}
		primes = append(primes, i)
	}
	return isPrime, primes
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	a, err := strconv.Atoi(Read())
	if err != nil {
		panic(err)
	}
	return a
}

func ReadInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt()
	}
	return ret
}

func ReadInt64() int64 {
	a, err := strconv.ParseInt(Read(), 10, 64)
	if err != nil {
		panic(err)
	}
	return a
}

func ReadInt64s(n int) []int64 {
	ret := make([]int64, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt64()
	}
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var nTest, n int

type pair struct {
	val int
	id  int
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n)
		odd := []pair{}
		even := []pair{}
		var x int
		for i := 0; i < n*2; i++ {
			fmt.Fscan(in, &x)

			if x&1 == 0 {
				even = append(even, pair{val: x, id: i + 1})
			} else {
				odd = append(odd, pair{val: x, id: i + 1})
			}
		}

		nOdd := len(odd) / 2 * 2
		nEven := 2*n - 2 - nOdd

		for i := 0; i < nOdd/2; i++ {
			fmt.Fprintln(out, odd[i*2].id, odd[i*2+1].id)
		}
		for i := 0; i < nEven/2; i++ {
			fmt.Fprintln(out, even[i*2].id, even[i*2+1].id)
		}
	}

	out.Flush()
}

package main

import (
	"fmt"
	"math"
)

const PI = math.Pi
const mod = 1e9 + 7

func main() {
	//rand.Seed(time.Now().UnixNano())
	var t int
	for fmt.Scan(&t);t>0;t-- {
		var n int
		fmt.Scan(&n)
		var j []int
		var o []int
		for i := 0; i < 2*n; i++ {
			k := 0
			fmt.Scan(&k)
			if k % 2 == 0 {
				o = append(o, i+1)
			}else {
				j = append(j, i+1)
			}
		}
		if len(j)%2 == 0 {
			for i := 0; i < len(j)-2; i+=2 {
				fmt.Println(j[i],j[i+1])
			}
			for i := 0; i < len(o); i+=2 {
				fmt.Println(o[i],o[i+1])
			}
		}else{
			for i := 0; i < len(j)-1; i+=2 {
				fmt.Println(j[i],j[i+1])
			}
			for i := 0; i < len(o)-1; i+=2 {
				fmt.Println(o[i],o[i+1])
			}
		}
	}
}

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)
var reader = bufio.NewReader(os.Stdin)

func readInt(delim byte) int {
    text, _ := reader.ReadString(delim)
    n, _ := strconv.ParseInt(strings.TrimSpace(text), 0, 32)
    return int(n)
}

func main() {
    t := readInt('\r')
    for i := 0; i < t; i++ {
        n := readInt('\r')
        lastOdd := -1
        lastEven := -1
        for j := 0; j < 2 * n - 2; j++ {
            curParity := readInt(' ') % 2
            if curParity == 0 {
                if lastEven != -1 {
                    fmt.Println(lastEven, j + 1)
                    lastEven = -1
                } else {
                    lastEven = j + 1
                }
            } else {
                if lastOdd != -1 {
                    fmt.Println(lastOdd, j + 1)
                    lastOdd = -1
                } else {
                    lastOdd = j + 1
                }
            }
        }
        if lastOdd == -1 && lastEven == -1 {
            _ = readInt(' ')
            _ = readInt('\r')
            continue
        }
        prev := readInt(' ') % 2
        if prev == 0 {
            fmt.Println(lastEven, 2*n - 1)
        }
        _ = readInt('\r')
    }
}

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)
var reader = bufio.NewReader(os.Stdin)

func readInt(delim byte) int {
    text, _ := reader.ReadString(delim)
    n, _ := strconv.ParseInt(strings.TrimSpace(text), 0, 32)
    return int(n)
}

func main() {
    t := readInt('\r')
    for i := 0; i < t; i++ {
        n := readInt('\r')
        lastOdd := -1
        lastEven := -1
        for j := 0; j < 2 * n - 2; j++ {
            curParity := readInt(' ') % 2
            if curParity == 0 {
                if lastEven != -1 {
                    fmt.Println(lastEven, j + 1)
                    lastEven = -1
                } else {
                    lastEven = j + 1
                }
            } else {
                if lastOdd != -1 {
                    fmt.Println(lastOdd, j + 1)
                    lastOdd = -1
                } else {
                    lastOdd = j + 1
                }
            }
        }
        if lastOdd == -1 && lastEven == -1 {
            continue
        }
        prev := readInt(' ') % 2
        if prev == 0 {
            fmt.Println(lastEven, 2*n - 1)
        }
        _ = readInt('\r')
    }
}

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)
var reader = bufio.NewReader(os.Stdin)

func readInt(delim byte) int {
    text, _ := reader.ReadString(delim)
    n, _ := strconv.ParseInt(strings.TrimSpace(text), 0, 32)
    return int(n)
}

func main() {
    t := readInt('\r')
    for i := 0; i < t; i++ {
        n := readInt('\r')
        lastOdd := -1
        lastEven := -1
        for j := 0; j < 2 * n - 2; j++ {
            curParity := readInt(' ') % 2
            if curParity == 0 {
                if lastEven != -1 {
                    fmt.Println(lastEven, j + 1)
                    lastEven = -1
                } else {
                    lastEven = j + 1
                }
            } else {
                if lastOdd != -1 {
                    fmt.Println(lastOdd, j + 1)
                    lastOdd = -1
                } else {
                    lastOdd = j + 1
                }
            }
        }
        prev := readInt(' ') % 2
        _ = readInt('\r')
        if (lastOdd == -1) != (lastEven == -1) {
            panic(1)
        }
        if lastOdd == -1 && lastEven == -1 {
            continue
        }
        if prev == 0 {
            fmt.Println(lastEven, 2*n - 1)
        }
    }
}


Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.There are n trees located along the road at points with coordinates x1, x2, ..., xn. Each tree has its height hi. Woodcutters can cut down a tree and fell it to the left or to the right. After that it occupies one of the segments [xi - hi, xi] or [xi;xi + hi]. The tree that is not cut down occupies a single point with coordinate xi. Woodcutters can fell a tree if the segment to be occupied by the fallen tree doesn't contain any occupied point. The woodcutters want to process as many trees as possible, so Susie wonders, what is the maximum number of trees to fell.

The first line contains integer n (1 ≤ n ≤ 105) — the number of trees. Next n lines contain pairs of integers xi, hi (1 ≤ xi, hi ≤ 109) — the coordinate and the height of the і-th tree. The pairs are given in the order of ascending xi. No two trees are located at the point with the same coordinate.

Print a single number — the maximum number of trees that you can cut down by the given rules.

NoteIn the first sample you can fell the trees like that:   fell the 1-st tree to the left — now it occupies segment [ - 1;1]  fell the 2-nd tree to the right — now it occupies segment [2;3]  leave the 3-rd tree — it occupies point 5  leave the 4-th tree — it occupies point 10  fell the 5-th tree to the right — now it occupies segment [19;20] In the second sample you can also fell 4-th tree to the right, after that it will occupy segment [10;19].

package main

import (
	"bufio"
	"fmt"
	"os"
)

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

var n int

func main() {
	defer w.Flush()
	for I(&n) == nil {
		solve(n)
	}
}

func solve(n int) {
	in := make([][2]int, n)
	for i := range in {
		I(&in[i][0], &in[i][1])
	}
	x := int(-1e9)
	ans := 0
	for i := 0; i < n; i++ {
		if x < in[i][0]-in[i][1] {
			x = in[i][0]
			ans++
		} else if x < in[i][0] && (i == n-1 || in[i+1][0] > in[i][0]+in[i][1]) {
			x = in[i][0] + in[i][1]
			ans++
		}
		if in[i][0] > x {
			x = in[i][0]
		}
	}
	O(ans, "\n")
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type RoadTree struct {
	Pos int
	Height int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var n int
	fmt.Scan(&n)
	scanner.Split(bufio.ScanWords)

	trees := make([]RoadTree, n)

	for i := 0; i < n; i++ {
		for scanner.Scan() {
			if scanner.Text() != "" { break }
		}

		position, _ := strconv.Atoi(scanner.Text())

		scanner.Scan()
		size, _ := strconv.Atoi(scanner.Text())

		trees[i] = RoadTree{position, size}
	}

	var fallenTrees int
	if fallenTrees = 2; fallenTrees > n {
		fallenTrees = n
	}

	for i := 1; i < n-1; i++ {
		if (trees[i].Pos - trees[i].Height) > trees[i - 1].Pos {
			fallenTrees += 1
		} else if (trees[i].Pos + trees[i].Height) < trees[i + 1].Pos {
			fallenTrees += 1
			trees[i].Pos += trees[i].Height
		}
	}

	fmt.Println(fallenTrees)
}

package main

import (
	"fmt"
	"os"
	"io/ioutil"
)

var (
	n int
	p int
	ibuf []byte
)

func IsDigit(b byte) bool {
	return '0' <= b && b <= '9'
}

func ReadInt() int {
	for ; p < len(ibuf) && !IsDigit(ibuf[p]); p++ {
	}
	d := 0
	for ; p < len(ibuf) && IsDigit(ibuf[p]); p++ {
		d = 10 * d + int(ibuf[p] - '0')
	}
	return d
}

func init() {
	p = 0
	ibuf, _ = ioutil.ReadAll(os.Stdin)
}

func main() {
	n := ReadInt()
	px, ph, pd := -1, -1, 0
	r := 0
	for i := 0; i < n; i++ {
		x, h := ReadInt(), ReadInt()
		if i == 0 {
			px, ph, pd = x, h, -1
		} else {
			if px + ph * pd >= x {
				pd = 0
			}
			if pd != 0 {
				r++
			}
			if px + ph * pd < x - h && px < x - h {
				px, ph, pd = x, h, -1
			} else {
				px, ph, pd = x, h, 1
			}
		}
	}
	r++
	fmt.Println(r)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

type tree struct {
	x, h int64
}

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	trees := make([]tree, n)
	var cnt int64 = 1
	haveOccupied := false

	if n >= 2 {
		cnt++
	}

	for i := range trees {
		trees[i].x = nextInt64()
		trees[i].h = nextInt64()
	}

	for i := 1; i < n-1; i++ {
		// println(trees[i].x, trees[i].h, haveOccupied, cnt)
		canChop := false
		if haveOccupied {
			if trees[i].x-trees[i].h > trees[i-1].x+trees[i-1].h {
				canChop = true
			}
		} else if trees[i].x-trees[i].h > trees[i-1].x {
			canChop = true
		}

		if canChop {
			cnt++
			haveOccupied = false
			continue
		}

		if trees[i].x+trees[i].h < trees[i+1].x {
			cnt++
			haveOccupied = true
		} else {
			haveOccupied = false
		}

		// if trees[i].x-trees[i].h > trees[i-1].x ||
		// 	trees[i].x+trees[i].h < trees[i+1].x {
		// 	cnt++
		// }
	}
	_ = haveOccupied
	println(cnt)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var in = bufio.NewScanner(os.Stdin)
var n, max int

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n = readInt()
  max = 1

  px, ph, pd := readInt(), readInt(), -1
  for i := 1; i < n; i++ {
    x, h := readInt(), readInt()
    if px+ph*pd >= x {
      pd = 0
    }
    if pd != 0 {
      max++
    }
    if px+ph*pd < x-h && px < x-h {
      px, ph, pd = x, h, -1
    } else {
      px, ph, pd = x, h, 1
    }
  }

  fmt.Println(max)
}

func readInt() int {
  in.Scan()
  n, _ := strconv.Atoi(in.Text())
  return n
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	cut := 0
	occupied := -1
	var x_i, h_i, last_x_i int

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < 2*n; i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if i%2 == 0 {
			if i > 0 {
				last_x_i = x_i
			}
			x_i = a
		} else {
			h_i = a
			if occupied < 0 {
				occupied = x_i
				cut++
			} else if occupied >= x_i {
				occupied = last_x_i
				cut--
				if x_i-h_i > occupied {
					occupied = x_i
					cut++
				} else {
					occupied = x_i + h_i
					cut++
				}
			} else if x_i-h_i > occupied {
				occupied = x_i
				cut++
			} else {
				occupied = x_i + h_i
				cut++
			}
		}
	}

	fmt.Println(cut)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanln(reader, &n)
	points := make([]int64, n)
	heights := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanln(reader, &points[i], &heights[i])
	}
	if n <= 2 {
		fmt.Fprintln(writer, n)
		return
	}
	trees := 2
	right_border := points[n-1]
	for i := n - 2; i >= 1; i-- {
		if points[i]+heights[i] < right_border {
			trees += 1
			right_border = points[i]
			continue
		}
		right_border = points[i]
		if points[i]-heights[i] > points[i-1] {
			trees += 1
			right_border -= heights[i]
			continue
		}
	}
	fmt.Fprintln(writer, trees)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

var n int
var x []int
var h []int

func max(a, b int) int {
	if a >= b {
		return a
	} else {
		return b
	}
}

const (
	LEFT     = iota
	RIGHT    = iota
	STAY     = iota
	SENTINEL = iota
)

func solve(i, lastChoice int) int {
	var left, right, stay int
	if i == n-1 {
		return 1 // always fall to the right
	}
	if lastChoice == SENTINEL {
		// always go left
		left = solve(i+1, LEFT) + 1
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == LEFT {
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == RIGHT {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1]+h[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == STAY {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	}
	//printf("i=%v, ans=%v\n", i, max(left, max(stay, right)))
	return max(left, max(stay, right))
}

func main() {
	defer writer.Flush()
	scanf("%d\n", &n)
	x = make([]int, n)
	h = make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d %d\n", &x[i], &h[i])
	}
	//printf("x=%v\n", x)
	//printf("h=%v\n", h)
	// ans := solve(0, SENTINEL)
	left := make([]int, n)
	right := make([]int, n)
	stay := make([]int, n)
	left[0] = 1
	stay[0] = 0
	if n > 1 && x[0]+h[0] < x[1] {
		right[0] = 1
	}
	for i := 1; i < n; i++ {
		if i == n-1 {
			right[i] = max(left[i-1], max(right[i-1], stay[i-1])) + 1
			continue
		}
		// falling left
		if x[i]-h[i] > x[i-1] {
			left[i] = max(left[i-1], stay[i-1]) + 1
		}
		if x[i-1]+h[i-1] < x[i]-h[i] {
			left[i] = max(left[i], right[i-1]+1)
		}
		// falling right
		if x[i]+h[i] < x[i+1] {
			if x[i-1]+h[i-1] < x[i] {
				right[i] = right[i-1] + 1
			}
			right[i] = max(right[i], max(left[i-1], stay[i-1])+1)
		}
		// stay
		stay[i] = max(left[i-1], stay[i-1])
		if x[i-1]+h[i-1] < x[i] {
			stay[i] = max(stay[i], right[i-1])
		}
	}
	printf("%v\n", max(stay[n-1], max(left[n-1], right[n-1])))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	n := ScanInt()
	x, h := make([]int, n+2), make([]int, n+2)
	x[0] = math.MinInt32
	h[0] = 0
	for i := 1; i <= n; i++ {
		x[i] = ScanInt()
		h[i] = ScanInt()
	}
	x[n+1] = math.MaxInt32
	h[n+1] = 0

	dp := make([][]int, n+2)
    for i := 0; i<n+2; i++ {
        dp[i] = make([]int, 3)
    }
	for i := 1; i <= n; i++ {
		dp[i][0] = Mx(dp[i-1][0], dp[i-1][1], dp[i-1][2])

		if int64(x[i])-int64(x[i-1]) > int64(h[i]) {
			dp[i][1] = Mx(dp[i-1][0], dp[i-1][1]) + 1
			if x[i]-x[i-1] > h[i]+h[i-1] {
				dp[i][1] = Mx(dp[i][1], dp[i-1][2]+1)
			}
		}
		if int64(x[i+1])-int64(x[i]) > int64(h[i]) {
			dp[i][2] = Mx(dp[i-1][0], dp[i-1][1], dp[i-1][2]) + 1
		}
	}

	P(dp[n][2])
	out.Flush()
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
	print("\n", nil)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case []int:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.Itoa(v[i]) + " ")
			}
			str = sb.String()
		case int64:
			str = strconv.FormatInt(v, 10)
		case []int64:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.FormatInt(v[i], 10) + " ")
			}
			str = sb.String()
		case string:
			str = v
		default:
			panic("invalid print arg: " + fmt.Sprintf("%v", arg))

		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}

func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	if err := run(os.Args[1:]); err != nil {
		fmt.Println(err)
	}
}

var reader = bufio.NewReader(os.Stdin)
var CRLFReplacer = strings.NewReplacer("\n", "", "\r", "")

func readString(w io.Writer) bool {
	s, err := reader.ReadString('\n')
	if err != nil {
		return false
	}
	s = CRLFReplacer.Replace(s)
	_, _ = fmt.Fprintf(w, "%s", s)
	return true
}

func MustInt(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

type tree struct {
	height int
	location int
	chopped bool
	left bool
}

func run(args []string) error {
	var b bytes.Buffer
	var forest []*tree

	readString(&b)
	b.Reset()

	for readString(&b) {
		s := b.String()
		parts := strings.Split(s, " ")
		t := &tree{
			height: MustInt(parts[1]),
			location: MustInt(parts[0]),
		}
		forest = append(forest, t)
		b.Reset()
	}

	count := 0

	for i, t := range forest {
		if i == 0 || i == len(forest) - 1 {
			t.chopped = true
			t.left = true
			count++
			continue
		}

		left := forest[i -1]
		if left.chopped && !left.left {
			if left.location + left.height < t.location - t.height {
				t.chopped = true
				t.left = true
				count++
				continue
			}
		} else {
			if left.location < t.location - t.height {
				t.chopped = true
				t.left = true
				count++
				continue
			}
		}

		right := forest[i + 1]
		if right.location > t.location + t.height {
			t.chopped = true
			t.left = false
			count++
			continue
		}
	}

	fmt.Println(count)
	return nil
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

var n int

func main() {
	defer w.Flush()
	for I(&n) == nil {
		solve(n)
	}
}

var in, C arr

func solve(n int) {
	in = make(arr, n)
	C = make(arr, n)
	for i := range in {
		I(&in[i][0], &in[i][1])
		C[i] = [3]int{in[i][0] - in[i][1], in[i][0], i}
	}
	sort.Sort(C)
	for i := range C {
		if i != n-1 && C[i+1][0] <= C[i][1] {
			C[i+1][0] = in[C[i+1][2]][0]
			C[i+1][1] = in[C[i+1][2]][0] + in[C[i+1][2]][1]
		}
	}
	for i := range C {
		if i != n-1 && C[i+1][0] <= C[i][1] {
			C[i+1][0] = in[C[i+1][2]][0]
			C[i+1][1] = in[C[i+1][2]][0]
		}
	}
	ans := 0
	for i := range C {
		if C[i][0] != C[i][1] {
			ans++
		}
	}
	O(ans, "\n")
}

type arr [][3]int

func (a arr) Len() int           { return len(a) }
func (a arr) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a arr) Less(i, j int) bool { return a[i][0] < a[j][0] }

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type RoadTree struct {
	Pos int
	Height int
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var n int
	fmt.Scan(&n)
	scanner.Split(bufio.ScanWords)

	trees := make([]RoadTree, n)

	for i := 0; i < n; i++ {
		for scanner.Scan() {
			if scanner.Text() != "" { break }
		}

		position, _ := strconv.Atoi(scanner.Text())

		scanner.Scan()
		size, _ := strconv.Atoi(scanner.Text())

		trees[i] = RoadTree{position, size}
	}

	var fallenTrees int
	if n < 2 {
		fallenTrees = n
	} else {
		fallenTrees = 2
	}

	for i := 1; i < n-1; i++ {
		// If can cut to the left
		if (trees[i].Pos - trees[i].Height) > trees[i - 1].Pos {
			fallenTrees += 1
		} else if (trees[i].Pos + trees[i].Height) < trees[i + 1].Pos {
			// If can cut to the right

			// If the next tree is the last tree then cut to the right, otherwise cut only if the next tree can't be cut
			// to the left.
			if i + 1 == n - 1 {
				fallenTrees += 1
			} else {
				if trees[i + 1].Pos - trees[i + 1].Height <= trees[i].Pos {
					fallenTrees += 1
					trees[i].Pos += trees[i].Height
				}
			}
		}
	}

	fmt.Println(fallenTrees)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

type tree struct {
	x, h int64
}

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	trees := make([]tree, n)
	var cnt int64 = 1

	if n >= 2 {
		cnt++
	}

	for i := range trees {
		trees[i].x = nextInt64()
		trees[i].h = nextInt64()
	}

	for i := 1; i < n-1; i++ {
		// println(trees[i].x, trees[i].h)
		if trees[i].x-trees[i].h > trees[i-1].x ||
			trees[i].x+trees[i].h < trees[i+1].x {
			cnt++
		}
	}

	println(cnt)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

type tree struct {
	x, h int64
}

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	trees := make([]tree, n)
	var cnt int64 = 1
	occupied := false

	if n >= 2 {
		cnt++
	}

	for i := range trees {
		trees[i].x = nextInt64()
		trees[i].h = nextInt64()
	}

	for i := 1; i < n-1; i++ {
		// println(trees[i].x, trees[i].h, occupied, cnt)
		if occupied {
			if trees[i].x-trees[i].h > trees[i-1].x+trees[i-1].h {
				cnt++
				occupied = false
				continue
			}
		} else if trees[i].x-trees[i].h > trees[i-1].x {
			cnt++
			occupied = false
			continue
		}

		if trees[i].x+trees[i].h < trees[i+1].x {
			cnt++
			occupied = true
		}
	}

	println(cnt)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	reader  = bufio.NewReader(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

type tree struct {
	x, h int64
}

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	trees := make([]tree, n)
	var cnt int64 = 1
	haveOccupied := false

	if n >= 2 {
		cnt++
	}

	for i := range trees {
		trees[i].x = nextInt64()
		trees[i].h = nextInt64()
	}

	for i := 1; i < n-1; i++ {
		// println(trees[i].x, trees[i].h, haveOccupied, cnt)
		canChop := false
		if haveOccupied {
			if trees[i].x-trees[i].h > trees[i-1].x+trees[i-1].h {
				canChop = true
			}
		} else if trees[i].x-trees[i].h > trees[i-1].x {
			canChop = true
		}

		if canChop {
			cnt++
			haveOccupied = false
			continue
		}

		if trees[i].x+trees[i].h < trees[i+1].x {
			cnt++
			haveOccupied = true
		}

		// if trees[i].x-trees[i].h > trees[i-1].x ||
		// 	trees[i].x+trees[i].h < trees[i+1].x {
		// 	cnt++
		// }
	}
	_ = haveOccupied
	println(cnt)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var in = bufio.NewScanner(os.Stdin)
var trees [100010][3]int
var maxis []int
var n, max int

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n = readInt()
  max = 0

  for i := 1; i <= n; i++ {
    trees[i][0], trees[i][1] = readInt(), readInt()
  }

  maxis = append(maxis, 1)
  maxis = append(maxis, -1)

  for i := 2; i <= n; i++ {
    for j := 0; j < len(maxis); j++ {
      idx := 0
      endPos := 0
      if maxis[j] < 0 {
        idx = maxis[j] * -1
        endPos = trees[idx][0]
      } else if maxis[j] > 0 {
        idx = maxis[j]
        endPos = trees[idx][0] + trees[idx][1]
      }

      if endPos <= trees[i][0]-trees[i][1] && (trees[i][0] < trees[i+1][0] || i == n) {
        trees[i][2] = trees[idx][2] + 1
        insertMax(i, true)
      }
      if endPos <= trees[i][0] && (trees[i][0]+trees[i][1] < trees[i+1][0] || i == n) {
        trees[i][2] = trees[idx][2] + 1
        insertMax(i, false)
      }
    }
  }
  fmt.Println(max + 1)
}

func readInt() int {
  in.Scan()
  n, _ := strconv.Atoi(in.Text())
  return n
}

func insertMax(i int, isleft bool) {
  if max < trees[i][2] {
    max = trees[i][2]
    maxis = maxis[:0]
    if isleft == true {
      maxis = append(maxis, i*-1)
    } else {
              maxis = append(maxis, i)
    }
  } else if max == trees[i][2] {
    if isleft == true {
      maxis = append(maxis, i*-1)
    } else {
      maxis = append(maxis, i)
    }
  }
}

package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var in = bufio.NewScanner(os.Stdin)
var trees [100010][2]int
var n, max int

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n = readInt()
  max = 1

  for i := 0; i < n; i++ {
    trees[i][0], trees[i][1] = readInt(), readInt()
  }

  for i := 1; i < n; i++ {
    ok := false

    if trees[i][0]-trees[i][1] > trees[i-1][0] || trees[i][0]-trees[i][1] > trees[i-1][0]+trees[i-1][0] {
      ok = true
    }
    if (trees[i][0] > trees[i-1][0]+trees[i-1][1] || trees[i][0] > trees[i-1][0]) && trees[i][0]+trees[i][1] < trees[i+1][0] {
      ok = true
    }

    if ok == true {
      max++
    }
  }

  fmt.Println(max)
}

func readInt() int {
  in.Scan()
  n, _ := strconv.Atoi(in.Text())
  return n
}

package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var in = bufio.NewScanner(os.Stdin)
var trees [100010][2]int
var n, max int

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n = readInt()
  max = 1

  for i := 0; i < n; i++ {
    trees[i][0], trees[i][1] = readInt(), readInt()
  }

  for i := 1; i < n; i++ {
    ok := false

    if trees[i][0]-trees[i][1] > trees[i-1][0] || trees[i][0]-trees[i][1] > trees[i-1][0]+trees[i-1][0] {
      ok = true
    }
    if (trees[i][0] > trees[i-1][0]+trees[i-1][1] || trees[i][0] > trees[i-1][0]) && (trees[i][0]+trees[i][1] < trees[i+1][0] || i == n-1) {
      ok = true
    }

    if ok == true {
      max++
    }
  }

  fmt.Println(max)
}

func readInt() int {
  in.Scan()
  n, _ := strconv.Atoi(in.Text())
  return n
}

package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
)

var in = bufio.NewScanner(os.Stdin)
var trees [100010][2]int
var n, max int

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n = readInt()
  max = 1

  for i := 0; i < n; i++ {
    trees[i][0], trees[i][1] = readInt(), readInt()
  }

  for i := 1; i < n; i++ {
    if (trees[i][0]-trees[i][1] > trees[i-1][0] || trees[i][0]-trees[i][1] > trees[i-1][0]+trees[i-1][0]) && trees[i][0] < trees[i+1][0] {
      max++
    } else if (trees[i][0] > trees[i-1][0]+trees[i-1][1] || trees[i][0] > trees[i-1][0]) && trees[i][0]+trees[i][1] < trees[i+1][0] {
      max++
    }
  }

  fmt.Println(max + 1)
}

func readInt() int {
  in.Scan()
  n, _ := strconv.Atoi(in.Text())
  return n
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

var n int
var x []int
var h []int

func max(a, b int) int {
	if a >= b {
		return a
	} else {
		return b
	}
}

const (
	LEFT     = iota
	RIGHT    = iota
	STAY     = iota
	SENTINEL = iota
)

func solve(i, lastChoice int) int {
	var left, right, stay int
	if i == n-1 {
		return 1 // always fall to the right
	}
	if lastChoice == SENTINEL {
		// always go left
		left = solve(i+1, LEFT) + 1
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == LEFT {
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == RIGHT {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1]+h[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == STAY {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	}
	//printf("i=%v, ans=%v\n", i, max(left, max(stay, right)))
	return max(left, max(stay, right))
}

func main() {
	defer writer.Flush()
	scanf("%d\n", &n)
	x = make([]int, n)
	h = make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d %d\n", &x[i], &h[i])
	}
	//printf("x=%v\n", x)
	//printf("h=%v\n", h)
	// ans := solve(0, SENTINEL)
	left := make([]int, n)
	right := make([]int, n)
	stay := make([]int, n)
	left[0] = 1
	stay[0] = 1
	if n > 1 && x[0]+h[0] < x[1] {
		right[0] = 1
	}
	for i := 1; i < n; i++ {
		if i == n-1 {
			right[i] = max(left[i-1], max(right[i-1], stay[i-1])) + 1
			continue
		}
		// falling left
		if x[i]-h[i] > x[i-1] {
			left[i] = max(left[i-1], stay[i-1]) + 1
		}
		if x[i-1]+h[i-1] < x[i]-h[i] {
			left[i] = max(left[i], right[i-1]+1)
		}
		// falling right
		if x[i]+h[i] < x[i+1] {
			if x[i-1]+h[i-1] < x[i] {
				right[i] = right[i-1] + 1
			}
			right[i] = max(left[i-1], stay[i-1]) + 1
		}
		// stay
		stay[i] = max(left[i-1], stay[i-1])
		if x[i-1]+h[i-1] < x[i] {
			stay[i] = max(stay[i], right[i-1])
		}
	}
	printf("%v\n", max(stay[n-1], max(left[n-1], right[n-1])))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

var n int
var x []int
var h []int

func max(a, b int) int {
	if a >= b {
		return a
	} else {
		return b
	}
}

const (
	LEFT     = iota
	RIGHT    = iota
	STAY     = iota
	SENTINEL = iota
)

func solve(i, lastChoice int) int {
	var left, right, stay int
	if i == n-1 {
		return 1 // always fall to the right
	}
	if lastChoice == SENTINEL {
		// always go left
		left = solve(i+1, LEFT) + 1
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == LEFT {
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == RIGHT {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1]+h[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == STAY {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	}
	//printf("i=%v, ans=%v\n", i, max(left, max(stay, right)))
	return max(left, max(stay, right))
}

func main() {
	defer writer.Flush()
	scanf("%d\n", &n)
	x = make([]int, n)
	h = make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d %d\n", &x[i], &h[i])
	}
	//printf("x=%v\n", x)
	//printf("h=%v\n", h)
	// ans := solve(0, SENTINEL)
	left := make([]int, n)
	right := make([]int, n)
	stay := make([]int, n)
	left[0] = 1
	stay[0] = 0
	right[0] = 1
	// if n > 1 && x[0]+h[0] < x[1] {
	// 	right[0] = 1
	// }
	for i := 1; i < n; i++ {
		if i == n-1 {
			right[i] = max(left[i-1], max(right[i-1], stay[i-1])) + 1
			continue
		}
		// falling left
		if x[i]-h[i] > x[i-1] {
			left[i] = max(left[i-1], stay[i-1]) + 1
		}
		if x[i-1]+h[i-1] < x[i]-h[i] {
			left[i] = max(left[i], right[i-1]+1)
		}
		// falling right
		if x[i]+h[i] < x[i+1] {
			if x[i-1]+h[i-1] < x[i] {
				right[i] = right[i-1] + 1
			}
			right[i] = max(left[i-1], stay[i-1]) + 1
		}
		// stay
		stay[i] = max(left[i-1], stay[i-1])
		if x[i-1]+h[i-1] < x[i] {
			stay[i] = max(stay[i], right[i-1])
		}
	}
	printf("%v\n", max(stay[n-1], max(left[n-1], right[n-1])))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

var n int
var x []int
var h []int

func max(a, b int) int {
	if a >= b {
		return a
	} else {
		return b
	}
}

const (
	LEFT     = iota
	RIGHT    = iota
	STAY     = iota
	SENTINEL = iota
)

func solve(i, lastChoice int) int {
	var left, right, stay int
	if i == n-1 {
		return 1 // always fall to the right
	}
	if lastChoice == SENTINEL {
		// always go left
		left = solve(i+1, LEFT) + 1
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == LEFT {
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == RIGHT {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1]+h[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == STAY {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	}
	//printf("i=%v, ans=%v\n", i, max(left, max(stay, right)))
	return max(left, max(stay, right))
}

func main() {
	defer writer.Flush()
	scanf("%d\n", &n)
	x = make([]int, n)
	h = make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d %d\n", &x[i], &h[i])
	}
	//printf("x=%v\n", x)
	//printf("h=%v\n", h)
	// ans := solve(0, SENTINEL)
	left := make([]int, n)
	right := make([]int, n)
	stay := make([]int, n)
	left[0] = 1
	stay[0] = 0
	if n > 1 && x[0]+h[0] < x[1] {
		right[0] = 1
	}
	for i := 1; i < n; i++ {
		if i == n-1 {
			right[i] = max(left[i-1], max(right[i-1], stay[i-1])) + 1
			continue
		}
		// falling left
		if x[i]-h[i] > x[i-1] {
			left[i] = max(left[i-1], stay[i-1]) + 1
		}
		if x[i-1]+h[i-1] < x[i]-h[i] {
			left[i] = max(left[i], right[i-1]+1)
		}
		// falling right
		if x[i]+h[i] < x[i+1] {
			if x[i-1]+h[i-1] < x[i] {
				right[i] = right[i-1] + 1
			}
			right[i] = max(left[i-1], stay[i-1]) + 1
		}
		// stay
		stay[i] = max(left[i-1], stay[i-1])
		if x[i-1]+h[i-1] < x[i] {
			stay[i] = max(stay[i], right[i-1])
		}
	}
	printf("%v\n", max(stay[n-1], max(left[n-1], right[n-1])))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

var n int
var x []int
var h []int

func max(a, b int) int {
	if a >= b {
		return a
	} else {
		return b
	}
}

const (
	LEFT     = iota
	RIGHT    = iota
	STAY     = iota
	SENTINEL = iota
)

func solve(i, lastChoice int) int {
	var left, right, stay int
	if i == n-1 {
		return 1 // always fall to the right
	}
	if lastChoice == SENTINEL {
		// always go left
		left = solve(i+1, LEFT) + 1
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == LEFT {
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == RIGHT {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1]+h[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	} else if lastChoice == STAY {
		if x[i]+h[i] < x[i+1] {
			right = solve(i+1, RIGHT) + 1
		}
		if x[i]-h[i] > x[i-1] {
			left = solve(i+1, LEFT) + 1
		}
		stay = solve(i+1, STAY)
	}
	//printf("i=%v, ans=%v\n", i, max(left, max(stay, right)))
	return max(left, max(stay, right))
}

func main() {
	defer writer.Flush()
	scanf("%d\n", &n)
	x = make([]int, n)
	h = make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d %d\n", &x[i], &h[i])
	}
	//printf("x=%v\n", x)
	//printf("h=%v\n", h)
	// ans := solve(0, SENTINEL)
	left := make([]int, n)
	right := make([]int, n)
	stay := make([]int, n)
	left[0] = 1
	stay[0] = 0
	if n > 1 && x[0]+h[0] < x[1] {
		right[0] = 1
	}
	for i := 1; i < n; i++ {
		if i == n-1 {
			right[i] = max(left[i-1], max(right[i-1], stay[i-1])) + 1
			continue
		}
		// falling left
		if x[i]-h[i] > x[i-1] {
			left[i] = max(left[i-1], stay[i-1]) + 1
		}
		if x[i-1]+h[i-1] < x[i]-h[i] {
			left[i] = max(left[i], right[i-1]+1)
		}
		// falling right
		if x[i]+h[i] < x[i+1] {
			if x[i-1]+h[i-1] < x[i] {
				right[i] = right[i-1] + 1
			}
			right[i] = max(right[i], max(left[i-1], stay[i-1])) + 1
		}
		// stay
		stay[i] = max(left[i-1], stay[i-1])
		if x[i-1]+h[i-1] < x[i] {
			stay[i] = max(stay[i], right[i-1])
		}
	}
	printf("%v\n", max(stay[n-1], max(left[n-1], right[n-1])))
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
		sum := 0
		n := ScanInt()
		blocked := math.MinInt32
		x := make([]int, n)
		h := make([]int, n)
		for i := 0; i < n; i++ {
			x[i], h[i] = ScanInt(), ScanInt()
		}
		x = append(x, math.MaxInt32)
		h = append(h, 0)

		for i := 0; i < n; i++ {
			if blocked <= x[i]-h[i] {
				sum++
				blocked = x[i]
			} else if x[i]+h[i] < x[i+1] {
				sum++
				blocked = x[i] + h[i]
			}
		}
		P(sum)

	out.Flush()
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
	print("\n", nil)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case []int:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.Itoa(v[i]) + " ")
			}
			str = sb.String()
		case int64:
			str = strconv.FormatInt(v, 10)
		case []int64:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.FormatInt(v[i], 10) + " ")
			}
			str = sb.String()
		case string:
			str = v
		default:
			panic("invalid print arg: " + fmt.Sprintf("%v", arg))

		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}

func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
		sum := 0
		n := ScanInt()
		blocked := math.MinInt32
		x := make([]int, n)
		h := make([]int, n)
		for i := 0; i < n; i++ {
			x[i], h[i] = ScanInt(), ScanInt()
		}
		x = append(x, math.MaxInt32)
		h = append(h, 0)

		for i := 0; i < n; i++ {
			if blocked < x[i]-h[i] {
				sum++
				blocked = x[i]
			} else if x[i]+h[i] < x[i+1] {
				sum++
				blocked = x[i] + h[i]
			}
		}
		P(sum)

	out.Flush()
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
	print("\n", nil)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case []int:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.Itoa(v[i]) + " ")
			}
			str = sb.String()
		case int64:
			str = strconv.FormatInt(v, 10)
		case []int64:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.FormatInt(v[i], 10) + " ")
			}
			str = sb.String()
		case string:
			str = v
		default:
			panic("invalid print arg: " + fmt.Sprintf("%v", arg))

		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}

func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	n := ScanInt()
	x, h := make([]int, n+2), make([]int, n+2)
	x[0] = math.MinInt32
	h[0] = 0
	for i := 1; i <= n; i++ {
		x[i] = ScanInt()
		h[i] = ScanInt()
	}
	x[n+1] = math.MaxInt32
	h[n+1] = 0

	dp := make([][3]int, n+2)

	for i := 1; i <= n; i++ {
		dp[i][0] = Mx(dp[i-1][0], dp[i-1][1], dp[i-1][2])

		if x[i]-x[i-1] > h[i] {
			dp[i][1] = Mx(dp[i-1][0], dp[i-1][1]) + 1
			if x[i]-x[i-1] > h[i]+h[i-1] {
				dp[i][1] = Mx(dp[i][1], dp[i-1][2]+1)
			}
		}
		if x[i+1]-x[i] > h[i] {
			dp[i][2] = Mx(dp[i-1][0], dp[i-1][1], dp[i-1][2]) + 1
		}
	}

	P(dp[n][2])
	out.Flush()
}

func main1() {
	sum := 0
	n := ScanInt()
	blocked := math.MinInt32
	x := make([]int, n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		x[i], h[i] = ScanInt(), ScanInt()
	}
	x = append(x, math.MaxInt32)
	h = append(h, 0)

	for i := 0; i < n; i++ {
		if blocked < x[i]-h[i] {
			sum++
			blocked = x[i]
		} else if x[i]+h[i] < x[i+1] {
			sum++
			blocked = x[i] + h[i]
		}
	}
	P(sum)

	out.Flush()
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
	print("\n", nil)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case []int:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.Itoa(v[i]) + " ")
			}
			str = sb.String()
		case int64:
			str = strconv.FormatInt(v, 10)
		case []int64:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.FormatInt(v[i], 10) + " ")
			}
			str = sb.String()
		case string:
			str = v
		default:
			panic("invalid print arg: " + fmt.Sprintf("%v", arg))

		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}

func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Because of budget cuts one IT company established new non-financial reward system instead of bonuses.Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table.Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought.In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table.One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants.

The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company.

Output one integer — the amount of ways to place the pennants on n tables.

/**
* FIXME: Use math/big
 */
package main

import (
	"fmt"
	"math/big"
)

const (
	// Number of pennants of type "I fixxed a critical bug"
	NUM_BUG_PENN int64 = 5
	// Number of pennants of type "I suggested a new feature"
	NUM_FEAT_PENN int64 = 3
)

/**
 *
 */
func comb(n, k *big.Int) *big.Int {
	var result, numer, denom, n_k *big.Int

	numer = big.NewInt(0)
	n_k = big.NewInt(0)
	denom = big.NewInt(0)
	result = big.NewInt(0)

	numer = factorial(n)
	n_k.Sub(n, k)
	denom.Mul(factorial(n_k), factorial(k))
	result.Div(numer, denom)

	return result
	//return factorial(n) / (factorial(n-k) * factorial(k))
}

/**
 *
 */
func factorial(n *big.Int) *big.Int {
	var i, prod *big.Int
	prod = big.NewInt(1)
	i = big.NewInt(2)

	//for ; i <= n; i++ {
	for !(i.Cmp(n) > 0) {
		prod.Mul(prod, i)
		i.Add(i, big.NewInt(1))
	}

	return prod
}

/**
 *
 */
func main() {
	var n int64
	fmt.Scanf("%d", &n)

	var nBig, bigNUM_BUG_PENN, bigNUM_FEAT_PENN *big.Int
	nBig = big.NewInt(n)
	bigNUM_BUG_PENN = big.NewInt(NUM_BUG_PENN)
	bigNUM_FEAT_PENN = big.NewInt(NUM_FEAT_PENN)

	var first, second, result *big.Int
	first = big.NewInt(NUM_BUG_PENN)
	first.Add(first, nBig)
	first.Sub(first, big.NewInt(1))

	second = big.NewInt(NUM_FEAT_PENN)
	second.Add(second, nBig)
	second.Sub(second, big.NewInt(1))

	result = big.NewInt(0)
	result.Mul(comb(first, bigNUM_BUG_PENN), comb(second, bigNUM_FEAT_PENN))
	fmt.Println(result)

	//fmt.Println(comb(nBig+NUM_BUG_PENN-1, bigNUM_BUG_PENN) *
	//	comb(nBig+NUM_FEAT_PENN-1, bigNUM_FEAT_PENN))
}

/**
 *
 */
package main

import (
	"fmt"
)

const (
	// Number of pennants of type "I fixxed a critical bug"
	NUM_BUG_PENN int64 = 5
	// Number of pennants of type "I suggested a new feature"
	NUM_FEAT_PENN int64 = 3
)

/**
 *
 */
func comb(n, k int64) int64 {
	return int64(factorial(n) / (factorial(n-k) * factorial(k)))
}

/**
 *
 */
func factorial(n int64) int64 {
	var (
		i    int64 = 2
		prod int64 = 1
	)

	for ; i <= n; i++ {
		prod *= i
	}

	return prod
}

/**
 *
 */
func main() {
	var n int64
	fmt.Scanf("%d", &n)

	fmt.Println(comb(n+NUM_BUG_PENN-1, NUM_BUG_PENN) *
		comb(n+NUM_FEAT_PENN-1, NUM_FEAT_PENN))
}

/**
 *
 */
package main

import (
	"fmt"
)

const (
	// Number of pennants of type "I fixxed a critical bug"
	NUM_BUG_PENN int = 5
	// Number of pennants of type "I suggested a new feature"
	NUM_FEAT_PENN int = 3
)

/**
 *
 */
func comb(n, k int) int {
	return int(factorial(n) / (factorial(n-k) * factorial(k)))
}

/**
 *
 */
func factorial(n int) int {
	prod := 1
	for i := 2; i <= n; i++ {
		prod *= i
	}
	return prod
}

/**
 *
 */
func main() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Println(comb(n+NUM_BUG_PENN-1, NUM_BUG_PENN) *
		comb(n+NUM_FEAT_PENN-1, NUM_FEAT_PENN))
}


You are given an array of integers $$$a_1, a_2, \ldots, a_n$$$ and an integer $$$x$$$.You need to select the maximum number of elements in the array, such that for every subsegment $$$a_l, a_{l + 1}, \ldots, a_r$$$ containing strictly more than one element $$$(l < r)$$$, either:   At least one element on this subsegment is not selected, or  $$$a_l + a_{l+1} + \ldots + a_r \geq x \cdot (r - l + 1)$$$.

The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 10$$$): the number of test cases. The descriptions of $$$t$$$ test cases follow, three lines per test case. In the first line you are given one integer $$$n$$$ ($$$1 \leq n \leq 50\,000$$$): the number of integers in the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-100\,000 \leq a_i \leq 100\,000$$$). The third line contains one integer $$$x$$$ ($$$-100\,000 \leq x \leq 100\,000$$$).

For each test case, print one integer: the maximum number of elements that you can select.

NoteIn the first example, one valid way to select the elements is $$$[\underline{1}, 2, \underline{3}, \underline{4}, \underline{5}]$$$. All subsegments satisfy at least one of the criteria. For example, for the subsegment $$$l = 1$$$, $$$r = 2$$$ we have that the element $$$2$$$ is not selected, satisfying the first criterion. For the subsegment $$$l = 3$$$, $$$r = 5$$$ we have $$$3 + 4 + 5 = 12 \ge 2 \cdot 3$$$, satisfying the second criterion.We can't select all elements, because in this case for $$$l = 1$$$, $$$r = 2$$$ all elements are selected and we have $$$a_1 + a_2 = 3 < 2 \cdot 2$$$. Thus, the maximum number of selected elements is $$$4$$$.In the second example, one valid solution is $$$[\underline{2}, \underline{4}, 2, \underline{4}, \underline{2}, \underline{4}, 2, \underline{4}, \underline{2}, \underline{4}]$$$.In the third example, one valid solution is $$$[\underline{-10}, -5, \underline{-10}]$$$.In the fourth example, one valid solution is $$$[\underline{9}, \underline{9}, -3]$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	var x int64
	scan(&x)
	var b = make([]int64, n)
	for i := range b {
		b[i] = int64(a[i])
		if i > 0 {
			b[i] += b[i-1]
		}
	}
	for i := range b {
		b[i] -= x * int64(i)
	}

	var (
		ans     = n
		prefmax = x
	)
	for i := 1; i < n; i++ {
		if b[i] >= prefmax {
			prefmax = max(prefmax, b[i-1])
			continue
		}
		ans--
		prefmax = b[i]
		i++
	}
	printf("%v\n", ans)
}

func max(s ...int64) int64 {
	r := s[0]
	for _, i := range s {
		if r < i {
			r = i
		}
	}
	return r
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	var x int64
	scan(&x)
	var b = make([]int64, n)
	for i := range b {
		b[i] = int64(a[i])
		if i > 0 {
			b[i] += b[i-1]
		}
	}
	for i := range b {
		b[i] -= x * int64(i)
	}
	var (
		_, bmin, _ = NewSparseTable(b, func(e1, e2 int64) int64 {
			if e1 < e2 {
				return e1
			}
			return e2
		})
		good = func(i, j int) bool {
			y := bmin(i+1, j)
			if i == 0 {
				return y >= x
			}
			return y >= b[i-1]
		}

		p, ans = n, n
	)
	for i := 0; i < len(b); i++ {
		if i == p {
			ans--
			p = n
			continue
		}
		l, r := i, len(b)
		for r-l > 1 {
			m := l + (r-l)/2
			if good(i, m) {
				l = m
			} else {
				r = m
			}
		}
		if p > r {
			p = r
		}
	}
	printf("%v\n", ans)
}

func NewSparseTable(s []int64, op func(x, y int64) int64) (tab [][]int64, get func(int, int) int64, log2 []int64) {
	var N = len(s)
	log2 = make([]int64, N+1)
	for i := 2; i <= N; i++ {
		log2[i] = log2[i>>1] + 1
	}
	tab = make([][]int64, log2[N]+1)
	for i := range tab {
		tab[i] = make([]int64, N)
	}
	for i := range tab[0] {
		tab[0][i] = s[i]
	}
	for i := 1; i <= int(log2[N]); i++ {
		for j := (1 << i) - 1; j < N; j++ {
			tab[i][j] = op(tab[i-1][j], tab[i-1][j-(1<<(i-1))])
		}
	}
	get = func(l, r int) int64 {
		log := log2[r-l+1]
		return op(tab[log][r], tab[log][l+(1<<log)-1])
	}
	return
}

/*	i > 0: p[j] - xj >= p[i-1] - x(i - 1)
	i = 0: p[j] - xj >= x

	 n=10, x=3
a	 2 4 2  4  2  4  2  4  2  4
b  3|2 3 2  3  2  3  2  3  2  3

	 n=3, x=-8
a	 -10 -5 -10
b -8|-10 -7  -9

for b[i] = p[i] - xi --> b[r] >= b[l-1]
*/

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1616D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var v, x int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		s := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &v)
			s[i] = s[i-1] + v
		}
		Fscan(in, &x)
		ans, mx, pre := n, int64(0), 0
		for i := range s {
			s[i] -= int64(i) * x
			if i >= pre+2 {
				if s[i-2] > mx {
					mx = s[i-2]
				}
				if mx > s[i] {
					mx = -1e18
					ans--
					pre = i
				}
			}
		}
		Fprintln(out, ans)
	}
}

func main() { CF1616D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func solveCase() int {
	var n, x int
	var a []int
	fmt.Fscan(in, &n)
	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}
	fmt.Fscan(in, &x)

	var ans = 0
	var segs [][]int
	for i := 0; i+1 < n; i++ {
		if a[i]+a[i+1] < x*2 {
			segs = append(segs, []int{i, i + 1})
		}
	}
	for i := 0; i+2 < n; i++ {
		if a[i]+a[i+1]+a[i+2] < x*3 {
			segs = append(segs, []int{i, i + 2})
		}
	}
	sort.Slice(segs, func(i, j int) bool {
		return segs[i][1] < segs[j][1]
	})

	var lastMarked = -3
	for _, seg := range segs {
		if lastMarked < seg[0] {
			lastMarked = seg[1]
			ans++
		}
	}
	return n - ans
}

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		fmt.Fprintf(out, "%d\n", solveCase())
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	var x int64
	scan(&x)
	var b = make([]int64, n)
	for i := range b {
		b[i] = int64(a[i])
		if i > 0 {
			b[i] += b[i-1]
		}
	}
	for i := range b {
		b[i] -= x * int64(i)
	}

	var (
		ans     = n
		prefmax = x
	)
	for i := 1; i < n; i++ {
		if b[i] >= prefmax {
			prefmax = max(prefmax, b[i-1])
			continue
		}
		ans--
		prefmax = b[i]
	}
	printf("%v\n", ans)
}

func max(s ...int64) int64 {
	r := s[0]
	for _, i := range s {
		if r < i {
			r = i
		}
	}
	return r
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	var x int64
	scan(&x)
	var b = make([]int64, n)
	for i := range b {
		b[i] = int64(a[i])
		if i > 0 {
			b[i] += b[i-1]
		}
	}
	for i := range b {
		b[i] -= x * int64(i)
	}
	var (
		max   func(int, int) int64
		check func(int, int) bool
		do    func(int, int) int
	)
	_, max, _ = NewSparseTable(b, func(e1, e2 int64) int64 {
		if e1 > e2 {
			return e1
		}
		return e2
	})
	check = func(l, r int) bool {
		if l == r {
			return true
		}
		if l == 0 {
			return x <= b[r]
		}
		return max(l-1, r-2) <= b[r]
	}
	do = func(i, j int) int {
		if i >= j {
			return 0
		}
		l, r := i-1, j+1
		for r-l > 1 {
			m := l + (r-l)/2
			if check(m, j) {
				r = m
			} else {
				l = m
			}
		}
		if r == i {
			return do(i, j-1)
		}
		return do(i, l-1) + 1 + do(r, j-1)
	}
	printf("%v\n", n-do(0, n-1))
}

func NewSparseTable(s []int64, op func(x, y int64) int64) (tab [][]int64, get func(int, int) int64, log2 []int64) {
	var N = len(s)
	log2 = make([]int64, N+1)
	for i := 2; i <= N; i++ {
		log2[i] = log2[i>>1] + 1
	}
	tab = make([][]int64, log2[N]+1)
	for i := range tab {
		tab[i] = make([]int64, N)
	}
	for i := range tab[0] {
		tab[0][i] = s[i]
	}
	for i := 1; i <= int(log2[N]); i++ {
		for j := (1 << i) - 1; j < N; j++ {
			tab[i][j] = op(tab[i-1][j], tab[i-1][j-(1<<(i-1))])
		}
	}
	get = func(l, r int) int64 {
		log := log2[r-l+1]
		return op(tab[log][r], tab[log][l+(1<<log)-1])
	}
	return
}

/*	i > 0: p[j] - xj >= p[i-1] - x(i - 1)
	i = 0: p[j] - xj >= x

	 n=10, x=3
a	 2 4 2  4  2  4  2  4  2  4
b  3|2 3 2  3  2  3  2  3  2  3

	 n=3, x=-8
a	 -10 -5 -10
b -8|-10 -7  -9

for b[i] = p[i] - xi --> b[r] >= b[l-1]
*/

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1616D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var v, x int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		s := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &v)
			s[i] = s[i-1] + v
		}
		Fscan(in, &x)
		ans, mx, pre := n, int64(0), 0
		for i := range s {
			s[i] -= int64(i) * x
			if i >= pre+2 {
				if s[i-2] > mx {
					mx = s[i-2]
				}
				if mx > s[i] {
					mx = -1e18
					ans--
					pre = i + 1
				}
			}
		}
		Fprintln(out, ans)
	}
}

func main() { CF1616D(os.Stdin, os.Stdout) }


We have a point $$$A$$$ with coordinate $$$x = n$$$ on $$$OX$$$-axis. We'd like to find an integer point $$$B$$$ (also on $$$OX$$$-axis), such that the absolute difference between the distance from $$$O$$$ to $$$B$$$ and the distance from $$$A$$$ to $$$B$$$ is equal to $$$k$$$.  The description of the first test case. Since sometimes it's impossible to find such point $$$B$$$, we can, in one step, increase or decrease the coordinate of $$$A$$$ by $$$1$$$. What is the minimum number of steps we should do to make such point $$$B$$$ exist?

The first line contains one integer $$$t$$$ ($$$1 \le t \le 6000$$$) — the number of test cases. The only line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$0 \le n, k \le 10^6$$$) — the initial position of point $$$A$$$ and desirable absolute difference.

For each test case, print the minimum number of steps to make point $$$B$$$ exist.

NoteIn the first test case (picture above), if we set the coordinate of $$$B$$$ as $$$2$$$ then the absolute difference will be equal to $$$|(2 - 0) - (4 - 2)| = 0$$$ and we don't have to move $$$A$$$. So the answer is $$$0$$$.In the second test case, we can increase the coordinate of $$$A$$$ by $$$3$$$ and set the coordinate of $$$B$$$ as $$$0$$$ or $$$8$$$. The absolute difference will be equal to $$$|8 - 0| = 8$$$, so the answer is $$$3$$$.

package main

import "fmt"

func main(){

    var t int
    var n int
    var k int

    fmt.Scanf("%d\n",&t)
    //fmt.Printf("%d\n", t);

    for i:=0 ; i<t ; i++ {
        fmt.Scanf("%d %d\n",&n,&k)
        //fmt.Printf("%d %d ",n,k)
        if n<=k {
            fmt.Printf("%d\n",k-n)
            continue
        }else{
            k = n-k
            fmt.Printf("%d\n",k%2)
        }
    }
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.NextInt(); t > 0; t-- {
		n, k := io.NextInt(), io.NextInt()
		ans := 0
		if n < k {
			ans = k - n
			n = k
		}
		if (n+k)%2 != 0 {
			ans++
		}
		io.Println(ans)
	}
}

type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, c)
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n, k int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &k)
		steps := 0
		if k > n {
			steps = k - n
		}
		if (n+steps-k)%2 != 0 {
			steps++
		}
		fmt.Println(steps)
	}
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"

	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 2 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {
		scanner.Scan()

		a := MustParseFields(scanner.Text())

		n := a[0]
		k := a[1]

		ans := solveA(n, k)
		fmt.Println(ans)
	}
}

func solveA(n, k int) int {
	if k == n {
		return 0
	}
	if k > n {
		return k - n
	}

	if (n - k) % 2 == 0 {
		return 0
	}

	return 1

}

func MustParseFields(str string) []int {
	parts := strings.Fields(str)

	var ints []int

	for i := 0; i < len(parts); i++ {
		v, err := strconv.Atoi(parts[i])

		if err != nil {
			panic(err)
		}
		ints = append(ints, v)
	}
	return ints
}

package main

import (
	"fmt"
)

func main() {
	var t int
	if _, err := fmt.Scanf("%d\n", &t); err != nil {
		panic(err)
	}

	for i := 0; i < t; i++ {
		var n, k int
		if _, err := fmt.Scanf("%d %d\n", &n, &k); err != nil {
			panic(err)
		}

		ans := 0
		if k >= n {
			ans = k - n
		} else if n % 2 != k % 2 {
			ans = 1
		}

		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := bufio.NewScanner(os.Stdin)

	if err := run(os.Args[1:], s); err != nil {
		fmt.Println(err)
	}
}

func run(args []string, s *bufio.Scanner) error {
	// Problem Logic Here... 😊
	s.Split(bufio.ScanWords)
	s.Scan()

	tc, err := strconv.Atoi(s.Text())
	if err != nil {
		return err
	}

	for tc > 0 && s.Scan() {
		a, err := strconv.Atoi(s.Text())
		if err != nil {
			return err
		}
		s.Scan()

		k, err := strconv.Atoi(s.Text())
		if err != nil {
			return err
		}

		fmt.Println(solve(a, k, 0))

		tc--
	}

	return nil
}

func solve(a, k, m int) int {
	if k <= a && a % 2 == k % 2 {
		return m
	}
	if k > a {
		return solve(k, k, m + (k - a))
	}
	return solve(a + 1, k, m + 1)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(r, &t)
	for i := 0; i < t; i++ {
		var n, k int
		fmt.Fscan(r, &n, &k)
		var rls int
		if n < k {
			rls = k - n
		} else if (n-k)%2 > 0 {
			rls = 1
		} else {
			rls = 0
		}
		fmt.Println(rls)
	}
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)

    for i := 0 ; i < t; i++ {
        var n, k int
        fmt.Scan(&n, &k)
        ans := 0
        if k < n {
          ans = (n - k) % 2
        } else {
            ans = k - n
        }
        fmt.Println(ans)
    }
}

func abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var rw = NewFastIO(os.Stdin, os.Stdout)

func main() {
	defer rw.Flush()
	nTest := 1
	nTest = rw.NextInt()
	for i := 0; i < nTest; i++ {
		solveCase()
	}
}

func solveCase() {
	n, k := rw.NextInt(), rw.NextInt()
	ans := 0
	if n < k {
		ans += k - n
		n = k
	}
	if (n-k)%2 == 1 {
		ans++
	}
	rw.Println(ans)

}

// @meooow template uwu
type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, c)
	}
	return string(s)
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}
func (f *FastIO) NextInt64() int64 {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := int64(0)
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int64(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}
func (f *FastIO) NextInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt64()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}
func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}
func (f *FastIO) PrintInt64s(a ...int64) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInt64s(a ...int64) {
	f.PrintInt64s(a...)
	f.Println()
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"

	"fmt"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 2 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {
		scanner.Scan()

		a := MustParseFields(scanner.Text())

		n := a[0]
		k := a[1]

		ans := solveA(n, k)
		fmt.Println(ans)
	}
}

func solveA(n, k int) int {
	if k == n {
		return 0
	}
	if k > n {
		return k - n
	}

	if (n - k) % 2 == 0 {
		return 0
	}
	return n - k

}

func MustParseFields(str string) []int {
	parts := strings.Fields(str)

	var ints []int

	for i := 0; i < len(parts); i++ {
		v, err := strconv.Atoi(parts[i])

		if err != nil {
			panic(err)
		}
		ints = append(ints, v)
	}
	return ints
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)

    for i := 0 ; i < t; i++ {
        var n, k int
        fmt.Scan(&n, &k)
        ans := 0
        if k < n {
            ans = n % 2
        } else {
            ans = k - n
        }
        fmt.Println(ans)
    }
}

func abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)

    for i := 0 ; i < t; i++ {
        var n, k int
        fmt.Scan(&n, &k)
        ans := 0
        if k == 0 {
            ans = n % 2
        } else if k < n {
          ans = abs(k * 2 - n)
        } else {
            ans = k - n
        }
        fmt.Println(ans)
    }
}

func abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)

    for i := 0 ; i < t; i++ {
        var n, k int
        fmt.Scan(&n, &k)
        ans := 0
        if k < n {
            ans = (n - k) / 2
            ans += (n - k) % 2
        } else {
            ans = k - n
        }
        fmt.Println(ans)
    }
}

func abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)

    for i := 0 ; i < t; i++ {
        var n, k int
        fmt.Scan(&n, &k)
        ans := 0
        if k == 0 {
            ans = n * 2
        } else if k < n {
          ans = abs(k * 2 - n)
        } else {
            ans = k - n
        }
        fmt.Println(ans)
    }
}

func abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}