There are $$$n$$$ students numerated from $$$1$$$ to $$$n$$$. The level of the $$$i$$$-th student is $$$a_i$$$. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements differ by more than $$$x$$$.For example, if $$$x = 4$$$, then the group with levels $$$[1, 10, 8, 4, 4]$$$ is stable (because $$$4 - 1 \le x$$$, $$$4 - 4 \le x$$$, $$$8 - 4 \le x$$$, $$$10 - 8 \le x$$$), while the group with levels $$$[2, 10, 10, 7]$$$ is not stable ($$$7 - 2 = 5 > x$$$).Apart from the $$$n$$$ given students, teachers can invite at most $$$k$$$ additional students with arbitrary levels (at teachers' choice). Find the minimum number of stable groups teachers can form from all students (including the newly invited).For example, if there are two students with levels $$$1$$$ and $$$5$$$; $$$x = 2$$$; and $$$k \ge 1$$$, then you can invite a new student with level $$$3$$$ and put all the students in one stable group.

The first line contains three integers $$$n$$$, $$$k$$$, $$$x$$$ ($$$1 \le n \le 200\,000$$$, $$$0 \le k \le 10^{18}$$$, $$$1 \le x \le 10^{18}$$$) — the initial number of students, the number of students you can additionally invite, and the maximum allowed level difference. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^{18}$$$) — the students levels.

In the only line print a single integer: the minimum number of stable groups you can split the students into.

NoteIn the first example you can invite two students with levels $$$2$$$ and $$$11$$$. Then you can split the students into two stable groups:   $$$[1, 1, 2, 5, 8, 11, 12, 13]$$$,  $$$[20, 22]$$$. In the second example you are not allowed to invite new students, so you need $$$3$$$ groups:   $$$[1, 1, 5, 5, 20, 20]$$$  $$$[60, 70, 70, 70, 80, 90]$$$  $$$[420]$$$

// link: https://codeforces.com/problemset/problem/1539/C

package main

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

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var k, x uint64
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &k)
	fmt.Fscan(in, &x)

	arr := make([]uint64, n)
	for i := 0; i < n; i++ {
		var val uint64
		fmt.Fscan(in, &val)

		arr[i] = val
	}

	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })

	var diffArr []uint64
	for i := 0; i < len(arr)-1; i++ {
		diff := arr[i+1] - arr[i]

		if diff > x {
			diffArr = append(diffArr, diff)
		}
	}

	sort.Slice(diffArr, func(i, j int) bool { return diffArr[i] < diffArr[j] })

	answer := 1
	for _, d := range diffArr {
		if k != 0 {
			var needCeil bool

			if d%x != 0 {
				needCeil = true
			}

			var kNeeded uint64
			if needCeil {
				kNeeded = d / x
			} else {
				kNeeded = (d / x) - 1
			}

			if k >= kNeeded {
				k -= kNeeded
			} else {
				answer++
				k = 0
			}
		} else {
			answer++
		}
	}

	fmt.Fprintln(out, answer)
}

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

package main

import (
	"bufio"
	"os"
	"fmt"

	"sort"
)

type ll []int64

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

type Tuples []tuple

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

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

	var n int
	fmt.Fscan(r, &n)

	var k, x int64
	fmt.Fscan(r, &k, &x)

	a := make([]int64, n)

	for j := 0; j < len(a); j++ {
		fmt.Fscan(r, &a[j])
	}

	ans := solve(a, k, x)

	fmt.Println(ans)
}

type tuple struct {
	d, l ,r int64
}

func solve(a []int64, k, x int64) int64 {
	sort.Sort(ll(a))

	allowed := k

	var diffs []tuple

	for i := 0; i < len(a); i++ {
		if i > 0 {
			diff := a[i] - a[i - 1]

			if diff > x {
				diffs = append(diffs, tuple{d: diff, l : a[i - 1], r : a[i]})
			}
		}
	}

	sort.Sort(Tuples(diffs))

	var cnt int64 = int64(len(diffs)) + 1

	for j := 0; j < len(diffs); j++ {

		tup := diffs[j]

		diff := tup.d

		if allowed > 0 {

			var d int64

			if diff % x == 0{
				d = diff/x
				d--
			} else {
				d = diff/x
			}

			if allowed >= d {
				allowed -=d
				cnt--
			}
		}
	}

	return cnt
}

package main

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

const (
	mx = 2e5 + 10
)

var n int
var k, x int64
var a [mx]int64

func hitung(n, x int64) int64 {
	return (n - 1) / x
}

func main() {

	var cin io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(cin, &n, &k, &x)

	for i := 0; i < n; i++ {
		fmt.Fscan(cin, &a[i])
	}

	sort.Slice(a[:n], func(i, j int) bool {
		return a[i] < a[j]
	})
	var gap []int64

	for i := 0; i < n-1; i++ {
		if a[i+1]-a[i] > x {
			gap = append(gap, hitung(a[i+1]-a[i], x))
		}
	}

	sort.Slice(gap, func(i, j int) bool {
		return gap[i] < gap[j]
	})

	kurang := 0

	for i := 0; i < len(gap); i++ {
		// fmt.Println(gap[i], k)
		if gap[i] <= k {
			k -= gap[i]
			kurang += 1
		}
	}

	fmt.Println(len(gap) - kurang + 1)
}

// 1 4 6 7 8 9 10

package main

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

/*
7 2 2
1 1 4 4 5 8 9 9
---
1
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	//scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		var k, x int64
		scanf("%d %d %d\n", &n, &k, &x)

		a := make([]int64, n)

		for i := range a {
			scanf("%d", &a[i])
		}

		sort.Slice(a, func(i, j int) bool {
			return a[i] < a[j]
		})

		gaps := make([]int64, 0)

		for i, num := range a {
			if i == 0 {
				continue
			}

			gap := num - a[i-1]
			if gap > x {
				gaps = append(gaps, gap)
			}
		}

		sort.Slice(gaps, func(i, j int) bool {
			return gaps[i] < gaps[j]
		})

		gapCnt := len(gaps)

		for _, gap := range gaps {
			cnt := (gap - 1) / x
			if cnt <= k {
				gapCnt--
				k -= cnt
			} else {
				break
			}
		}

		segCnt := gapCnt + 1

		fmt.Fprintln(writer, segCnt)
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int64) int64 {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1539C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	var k, x int64
	Fscan(in, &n, &k, &x)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

	gap := []int64{}
	for i := 1; i < n; i++ {
		if d := a[i] - a[i-1]; d > x {
			gap = append(gap, d)
		}
	}
	sort.Slice(gap, func(i, j int) bool { return gap[i] < gap[j] })

	for len(gap) > 0 {
		c := (gap[0] - 1) / x
		if c > k {
			break
		}
		k -= c
		gap = gap[1:]
	}
	Fprint(out, len(gap)+1)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1539C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	var k, x int64
	Fscan(in, &n, &k, &x)
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

	gap := []int64{}
	for i := 0; i < n; {
		for i++; i < n && a[i]-a[i-1] <= x; i++ {
		}
		if i < n {
			gap = append(gap, a[i]-a[i-1])
		}
	}
	sort.Slice(gap, func(i, j int) bool { return gap[i] < gap[j] })

	for len(gap) > 0 {
		c := (gap[0] - 1) / x
		if c > k {
			break
		}
		k -= c
		gap = gap[1:]
	}
	Fprint(out, len(gap)+1)
}

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

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pfl, _ := Readln(reader) // first liue:  _, nums of additional, dif
	fl := strings.Split(pfl, " ")
	add, _ := strconv.ParseInt(fl[1], 10, 64)
	dif, _ := strconv.ParseInt(fl[2], 10, 64)

	psl, _ := Readln(reader)
	sl := strings.Split(psl, " ")
	s := make([] int64, len(sl))
	for i := range sl {
		s[i], _ = strconv.ParseInt(sl[i], 10, 64)
	}
	sort.Slice(s, func(i, j int) bool {
		return s[i] < s[j]
	})

	curGroups := 1
	insertsNeeded := make([] int64, 0)

	for i:=0; i<len(s)-1; i++ {
		if s[i+1]-s[i] >  dif {
			curGroups++
			insertsNeeded = append(insertsNeeded, (s[i+1]-s[i] -1 ) / dif)
		}
	}
	sort.Slice(insertsNeeded, func(i,j int) bool {
		return insertsNeeded[i] < insertsNeeded[j]
	})

	for add > 0 {
		if len(insertsNeeded) != 0  {
			a:= insertsNeeded[0]
			insertsNeeded = insertsNeeded[1:]
			add -= a
			if add >= 0 {
				curGroups--
			}
			continue
		}
		break
	}

	//fmt.Println(add)
	//
	//fmt.Println(cur_groups)
	//fmt.Println(inserts_needed)

	fmt.Println(curGroups)

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	var n, x, k int64
	fmt.Fscan(input, &n)
	fmt.Fscan(input, &k)
	fmt.Fscan(input, &x)

	ARRAY := make([]int64, n)
	for i := 0; int64(i) < n; i++ {
		fmt.Fscan(input, &ARRAY[i])

	}

	sort.Slice(ARRAY, func(i, j int) bool {
		return ARRAY[i] < ARRAY[j]
	})
	BAA := make([]int64, 0)
	for i := 1; int64(i) < n; i++ {
		QQ := ARRAY[i] - ARRAY[i-1]
		var g int64
		g = int64((QQ - 1) / x)
		if g > 0 {
			BAA = append(BAA, g)
		}
	}

	sort.Slice(BAA, func(i, j int) bool {
		return BAA[i] < BAA[j]
	})
	w := len(BAA)
	if w == 0 {
		fmt.Println(1)
	} else {
		var inddd int64
		var sum int64
		for i := 0; i < w; i++ {
			if sum+BAA[i] < k+1 {
				sum = sum + BAA[i]
				inddd++
			} else {
				break
			}
		}
		fmt.Println(int64(w) + 1 - inddd)

	}

}

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Int64() int64 {
    s.scanner.Scan()
    n, _ := strconv.ParseInt(s.scanner.Text(), 10, 64)

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func solve(vec []int64, n int, k, x int64) int64 {
    sort.Slice(vec, func(i, j int) bool { return vec[i] < vec[j] })

    var needed []int64 = nil
    for i := 1; i < n; i += 1 {
        diff := vec[i] - vec[i - 1]
        if diff > x {
            needed = append(needed, (diff - 1) / x)
        }
    }
    sort.Slice(needed, func(i, j int) bool { return needed[i] < needed[j] })

    groups := int64(len(needed)) + 1
    for i := 0; i < len(needed); i += 1 {
        if needed[i] <= k {
            k -= needed[i]
            groups -= 1
        } else {
            break
        }
    }
    return groups
}

func main() {
    scanner := StdinScanner()
    n, k, x := scanner.Int(), scanner.Int64(), scanner.Int64()

    vec := make([]int64, n)
    for i := 0; i < n; i += 1 {
        vec[i] = scanner.Int64()
    }

    res := solve(vec, n, k, x)
    fmt.Println(res)
}

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var n, k, x int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &n, &k, &x)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &a[i])
	}
	sort.Ints(a)
	gaps := make([]int, 0)
	for i := 1; i < n; i++ {
		gap := a[i] - a[i-1]
		if gap > x {
			g := gap / x
			if gap%x == 0 {
				g--
			}
			gaps = append(gaps, g)
		}
	}
	sort.Ints(gaps)
	rm := 0
	for i := 0; i < len(gaps); i++ {
		if gaps[i] <= k {
			k -= gaps[i]
			rm++
		} else {
			break
		}
	}
	write(f, len(gaps)-rm+1, "\n")
}

package main

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

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...) }

func main() {
	var k, x int64
	var n int

	scanf("%d %d %d\n", &n, &k, &x)
	mas := make([]int64, n)
	for i := range mas {
		scanf("%d", &mas[i])
	}
	sort.Slice(mas, func(i, j int) bool {
		return mas[i] < mas[j]
	})
	mc := make([]int64, n-1)
	for i := range mc {
		if mas[i+1] > mas[i] {
			mc[i] = (mas[i+1] - mas[i] - 1) / x
		}
	}
	sort.Slice(mc, func(i, j int) bool {
		return mc[i] < mc[j]
	})
	i := 0
	for ; i < n-1 && mc[i] <= k; i++ {
		k -= mc[i]
	}
	printf("%d\n", n-i)
	writer.Flush()
}

// link: https://codeforces.com/problemset/problem/1539/C

package main

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

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var k, x uint64
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &k)
	fmt.Fscan(in, &x)

	arr := make([]uint64, n)
	for i := 0; i < n; i++ {
		var val uint64
		fmt.Fscan(in, &val)

		arr[i] = val
	}

	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })

	var diffArr []uint64
	for i := 0; i < len(arr)-1; i++ {
		diff := arr[i+1] - arr[i]

		if diff > x {
			diffArr = append(diffArr, diff)
		}
	}

	sort.Slice(diffArr, func(i, j int) bool { return diffArr[i] < diffArr[j] })

	answer := 1
	for _, d := range diffArr {
		if k != 0 {
			kNeeded := uint64(math.Ceil(float64(d)/float64(x)) - 1)

			if k >= kNeeded {
				k -= kNeeded
			} else {
				if n == 200000 && k == 499999999999999999 && x == 2 {
					fmt.Fprintf(out, "inn else, kNeeded=%d, k=%d, d=%d", kNeeded, k, d)
				}
				answer++
				k = 0
			}
		} else {
			if n == 200000 && k == 499999999999999999 && x == 2 {
				fmt.Fprintf(out, "out else, k=%d, d=%d", k, d)
			}
			answer++
		}
	}

	fmt.Fprintln(out, answer)
}

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

// link: https://codeforces.com/problemset/problem/1539/C

package main

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

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var k, x uint64
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &k)
	fmt.Fscan(in, &x)

	arr := make([]uint64, n)
	for i := 0; i < n; i++ {
		var val uint64
		fmt.Fscan(in, &val)

		arr[i] = val
	}

	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })

	var diffArr []uint64
	for i := 0; i < len(arr)-1; i++ {
		diff := arr[i+1] - arr[i]

		if diff > x {
			diffArr = append(diffArr, diff)
		}
	}

	sort.Slice(diffArr, func(i, j int) bool { return diffArr[i] < diffArr[j] })

	answer := 1
	for _, d := range diffArr {
		if k != 0 {
			kNeeded := uint64(math.Ceil(float64(d)/float64(x)) - 1)

			if k >= kNeeded {
				k -= kNeeded
			} else {
				fmt.Fprintf(out, "inn else, kNeeded=%d, k=%d, d=%d", kNeeded, k, d)
				answer++
				k = 0
			}
		} else {
			fmt.Fprintf(out, "out else, k=%d, d=%d", k, d)
			answer++
		}
	}

	fmt.Fprintln(out, answer)
}

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

// link: https://codeforces.com/problemset/problem/1539/C

package main

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

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var k, x uint64
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &k)
	fmt.Fscan(in, &x)

	arr := make([]uint64, n)
	for i := 0; i < n; i++ {
		var val uint64
		fmt.Fscan(in, &val)

		arr[i] = val
	}

	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })

	var diffArr []uint64
	for i := 0; i < len(arr)-1; i++ {
		diff := arr[i+1] - arr[i]

		if diff > x {
			diffArr = append(diffArr, diff)
		}
	}

	sort.Slice(diffArr, func(i, j int) bool { return diffArr[i] < diffArr[j] })

	answer := 1
	for _, d := range diffArr {
		if k != 0 {
			kNeeded := uint64(math.Ceil(float64(d)/float64(x)) - 1)

			if k >= kNeeded {
				k -= kNeeded
			} else {
				answer++
				k = 0
			}
		} else {
			answer++
		}
	}

	fmt.Fprintln(out, answer)
}

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

// link: https://codeforces.com/problemset/problem/1539/C

package main

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

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var k, x uint64
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &k)
	fmt.Fscan(in, &x)

	arr := make([]uint64, n)
	for i := 0; i < n; i++ {
		var val uint64
		fmt.Fscan(in, &val)

		arr[i] = val
	}

	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })

	answer := 1

	for i := 0; i < len(arr)-1; i++ {
		diff := arr[i+1] - arr[i]

		if diff > x {
			if k != 0 && diff <= x*2 {
				k--
			} else {
				answer++
			}
		}
	}

	fmt.Fprintln(out, answer)
}

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

// link: https://codeforces.com/problemset/problem/1539/C

package main

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

func logic(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var k, x uint64
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &k)
	fmt.Fscan(in, &x)

	arr := make([]uint64, n)
	for i := 0; i < n; i++ {
		var val uint64
		fmt.Fscan(in, &val)

		arr[i] = val
	}

	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })

	answer := 1

	for i := 0; i < len(arr)-1; i++ {
		diff := arr[i+1] - arr[i]

		if diff > x {
			if k != 0 && diff < x*2 {
				k--
			} else {
				answer++
			}
		}
	}

	fmt.Fprintln(out, answer)
}

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

package main

import (
	"bufio"
	"os"
	"fmt"

	"sort"
)

type ll []int64

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

type Tuples []tuple

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

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

	var n int
	fmt.Fscan(r, &n)

	var k, x int64
	fmt.Fscan(r, &k, &x)

	a := make([]int64, n)

	for j := 0; j < len(a); j++ {
		fmt.Fscan(r, &a[j])
	}

	ans := solve(a, k, x)

	fmt.Println(ans)
}

type tuple struct {
	d, l ,r int64
}

func solve(a []int64, k, x int64) int64 {
	sort.Sort(ll(a))

	allowed := k

	var diffs []tuple

	for i := 0; i < len(a); i++ {
		if i > 0 {
			diff := a[i] - a[i - 1]

			if diff > x {
				diffs = append(diffs, tuple{d: diff, l : a[i - 1], r : a[i]})
			}
		}
	}

	sort.Sort(Tuples(diffs))

	var cnt int64 = int64(len(diffs)) + 1

	for j := 0; j < len(diffs); j++ {

		tup := diffs[j]

		if allowed > 0 {

			start := tup.l + x

			var d int64

			d = (tup.r - start)/x
			d++

			if allowed >= d {
				allowed -=d
				cnt--
			}
		}
	}

	return cnt
}

package main

import (
	"bufio"
	"os"
	"fmt"

	"sort"
)

type ll []int64

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

type Tuples []tuple

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

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

	var n int
	fmt.Fscan(r, &n)

	var k, x int64
	fmt.Fscan(r, &k, &x)

	a := make([]int64, n)

	for j := 0; j < len(a); j++ {
		fmt.Fscan(r, &a[j])
	}

	ans := solve(a, k, x)

	fmt.Println(ans)
}

type tuple struct {
	d, l ,r int64
}

func solve(a []int64, k, x int64) int64 {
	sort.Sort(ll(a))

	allowed := k

	var diffs []tuple

	for i := 0; i < len(a); i++ {
		if i > 0 {
			diff := a[i] - a[i - 1]

			if diff > x {
				diffs = append(diffs, tuple{d: diff, l : a[i - 1], r : a[i]})
			}
		}
	}

	sort.Sort(Tuples(diffs))

	var cnt int64 = int64(len(diffs)) + 1

	for j := 0; j < len(diffs); j++ {

		tup := diffs[j]

		if allowed > 0 {

			start := tup.l + tup.d

			var d int64

			d = (tup.r - start)/x
			d++

			if allowed >= d {
				allowed -=d
				cnt--
			}
		}
	}

	return cnt
}

package main

import (
	"bufio"
	"os"
	"fmt"

	"sort"
)

type ll []int64

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

type Tuples []tuple

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

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

	var n int
	fmt.Fscan(r, &n)

	var k, x int64
	fmt.Fscan(r, &k, &x)

	a := make([]int64, n)

	for j := 0; j < len(a); j++ {
		fmt.Fscan(r, &a[j])
	}

	ans := solve(a, k, x)

	fmt.Println(ans)
}

type tuple struct {
	d, l ,r int64
}

func solve(a []int64, k, x int64) int64 {
	sort.Sort(ll(a))

	var cnt int64 = 1
	allowed := k

	var diffs []tuple

	for i := 0; i < len(a); i++ {
		if i > 0 {
			diff := a[i] - a[i - 1]

			if diff > x {
				diffs = append(diffs, tuple{d: diff, l : a[i - 1], r : a[i]})
			}
		}
	}

	sort.Sort(Tuples(diffs))

	for j := 0; j < len(diffs); j++ {

		tup := diffs[j]

		if allowed > 0 {

			start := tup.l + tup.d

			var d int64

			d = (tup.r - start)/x
			d++

			if allowed >= d {
				allowed -=d
			} else {
				cnt++
			}

		} else {
			cnt++
		}
	}

	return cnt
}

package main

import (
	"bufio"
	"os"
	"fmt"

	"sort"
)

type ll []int64

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

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

	var n int
	fmt.Fscan(r, &n)

	var k, x int64
	fmt.Fscan(r, &k, &x)

	a := make([]int64, n)

	for j := 0; j < len(a); j++ {
		fmt.Fscan(r, &a[j])
	}

	ans := solve(a, k, x)

	fmt.Println(ans)
}

func solve(a []int64, k, x int64) int64 {
	sort.Sort(ll(a))

	var cnt int64 = 1
	allowed := k

	var diffs []int64

	for i := 0; i < len(a); i++ {
		if i > 0 {

			diff := a[i] - a[i - 1]

			if diff > x {

				diffs = append(diffs, diff)

			}
		}
	}

	sort.Sort(ll(diffs))

	for j := 0; j < len(diffs); j++ {

		diff := diffs[j]

		if allowed > 0 {

			var d int64

			if diff % x == 0 {
				d := diff/x
				d--

			} else {
				d = diff/x
			}

			if allowed >= d {
				allowed -=d
			} else {
				cnt++
			}

		} else {
			cnt++
		}
	}

	return cnt
}

package main

import (
	"bufio"
	"os"
	"fmt"

	"sort"
)

type ll []int64

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

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

	var n int
	fmt.Fscan(r, &n)

	var k, x int64
	fmt.Fscan(r, &k, &x)

	a := make([]int64, n)

	for j := 0; j < len(a); j++ {
		fmt.Fscan(r, &a[j])
	}

	ans := solve(a, k, x)

	fmt.Println(ans)
}

func solve(a []int64, k, x int64) int64 {
	sort.Sort(ll(a))

	var cnt int64 = 1
	allowed := k

	for i := 0; i < len(a); i++ {
		if i > 0 {

			diff := a[i] - a[i - 1]

			if diff > x {

				if allowed > 0 {
					start := a[i - 1] + x

					d := (a[i] - start)/x
					d++

					if allowed >= d {
						allowed -=d
					} else {
						cnt++
					}

				} else {
					cnt++
				}
			}
		}
	}

	return cnt
}

package main

import (
	"fmt"
	"sort"
)

const (
	mx = 1e5 + 10
)

var n int
var k, x int64
var a [mx]int64

func hitung(n, x int64) int64 {
	return (n - 1) / x
}

func main() {

	fmt.Scanf("%d%d%d", &n, &k, &x)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	sort.Slice(a[:n], func(i, j int) bool {
		return a[i] < a[j]
	})
	var gap []int64

	for i := 0; i < n-1; i++ {
		if a[i+1]-a[i] > x {
			gap = append(gap, hitung(a[i+1]-a[i], x))
		}
	}

	sort.Slice(gap, func(i, j int) bool {
		return gap[i] < gap[j]
	})

	kurang := 0

	for i := 0; i < len(gap); i++ {
		// fmt.Println(gap[i], k)
		if gap[i] <= k {
			k -= gap[i]
			kurang += 1
		}
	}

	fmt.Println(len(gap) - kurang + 1)
}

// 1 4 6 7 8 9 10

package main

import (
	"fmt"
	"sort"
)

const (
	mx = 1e5 + 10
)

var n int
var k, x int64
var a [mx]int64

func hitung(n, x int64) int64 {
	return (n - 1) / x
}

func main() {

	fmt.Scanf("%d%d%d", &n, &k, &x)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	sort.Slice(a[:n], func(i, j int) bool {
		return a[i] < a[j]
	})
	var gap []int64

	for i := 0; i < n-1; i++ {
		if a[i+1]-a[i] > x {
			gap = append(gap, hitung(a[i+1]-a[i], x))
		}
	}

	sort.Slice(gap, func(i, j int) bool {
		return gap[i] < gap[j]
	})

	kurang := 0

	for i := 0; i < len(gap); i++ {
		if gap[i] <= k {
			k -= gap[i]
			kurang += 1
		}
	}

	fmt.Println(len(gap) - kurang + 1)
}

package main

import (
	"fmt"
	"sort"
)

const (
	mx = 1e5 + 10
)

var n int
var k, x int64
var a [mx]int64

func hitung(n, x int64) int64 {
	return n / x
}

func main() {

	fmt.Scanf("%d%d%d", &n, &k, &x)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	sort.Slice(a[:n], func(i, j int) bool {
		return a[i] < a[j]
	})
	var gap []int64

	for i := 0; i < n-1; i++ {
		if a[i+1]-a[i] > x {
			gap = append(gap, hitung(a[i+1]-a[i], x))
		}
	}

	sort.Slice(gap, func(i, j int) bool {
		return gap[i] < gap[j]
	})

	kurang := 0

	for i := 0; i < len(gap); i++ {
		if gap[i] <= k {
			k -= gap[i]
			kurang += 1
		}
	}

	fmt.Println(len(gap) - kurang + 1)
}

package main

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

/*
7 2 2
1 1 4 4 5 8 9 9
---
1

gap	x
2	1

3 2

_S_		3 / (2+1) = 1

_S__	4 / (2+1) =	1

__S__ 	5 / (2+1) = 1

_S__S_	6 / (2+1) = 2

gap / (x+1)
s<-x->s<-x->
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	//scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		var k, x int64
		scanf("%d %d %d\n", &n, &k, &x)

		a := make([]int64, n)

		for i := range a {
			scanf("%d", &a[i])
		}

		sort.Slice(a, func(i, j int) bool {
			return a[i] < a[j]
		})

		gaps := make([]int64, 0)

		for i, num := range a {
			if i == 0 {
				continue
			}

			gap := num - a[i-1]
			if gap > x {
				gaps = append(gaps, gap)
			}
		}

		sort.Slice(gaps, func(i, j int) bool {
			return gaps[i] < gaps[j]
		})

		gapCnt := len(gaps)

		for _, gap := range gaps {
			cnt := gap / (x + 1)
			if cnt <= k {
				gapCnt--
				k -= cnt
			} else {
				break
			}
		}

		segCnt := gapCnt + 1

		fmt.Fprintln(writer, segCnt)
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int64) int64 {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	var n, x, k int64
	fmt.Fscan(input, &n)
	fmt.Fscan(input, &k)
	fmt.Fscan(input, &x)

	ARRAY := make([]int64, n)
	for i := 0; int64(i) < n; i++ {
		fmt.Fscan(input, &ARRAY[i])

	}

	sort.Slice(ARRAY, func(i, j int) bool {
		return ARRAY[i] < ARRAY[j]
	})
	BAA := make([]int64, 0)
	for i := 1; int64(i) < n; i++ {
		QQ := ARRAY[i] - ARRAY[i-1]
		var g int64
		g = int64((QQ - 1) / x)
		if g > 0 {
			BAA = append(BAA, g)
		}
	}

	sort.Slice(BAA, func(i, j int) bool {
		return BAA[i] < BAA[j]
	})
	w := len(BAA)
	if w == 0 {
		fmt.Println(0)
	} else {
		var inddd int64
		var sum int64
		for i := 0; i < w; i++ {
			if sum+BAA[i] < k+1 {
				sum = sum + BAA[i]
				inddd++
			} else {
				break
			}
		}
		fmt.Println(int64(w) + 1 - inddd)

	}

}

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Int64() int64 {
    s.scanner.Scan()
    n, _ := strconv.ParseInt(s.scanner.Text(), 10, 64)

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func solve(vec []int64, n int, k, x int64) int64 {
    sort.Slice(vec, func(i, j int) bool { return vec[i] < vec[j] })

    var diffs []int64 = nil
    for i := 1; i < n; i += 1 {
        diff := vec[i] - vec[i - 1]
        if diff > x {
            diffs = append(diffs, diff / x)
        }
    }
    sort.Slice(diffs, func(i, j int) bool { return diffs[i] < diffs[j] })

    groups := int64(len(diffs)) + 1
    for i := 0; i < len(diffs); i += 1 {
        if diffs[i] <= k {
            k -= diffs[i]
            groups -= 1
        }
    }
    return groups
}

func main() {
    scanner := StdinScanner()
    n, k, x := scanner.Int(), scanner.Int64(), scanner.Int64()

    vec := make([]int64, n)
    for i := 0; i < n; i += 1 {
        vec[i] = scanner.Int64()
    }

    res := solve(vec, n, k, x)
    fmt.Println(res)
}


XXI Berland Annual Fair is coming really soon! Traditionally fair consists of $$$n$$$ booths, arranged in a circle. The booths are numbered $$$1$$$ through $$$n$$$ clockwise with $$$n$$$ being adjacent to $$$1$$$. The $$$i$$$-th booths sells some candies for the price of $$$a_i$$$ burles per item. Each booth has an unlimited supply of candies.Polycarp has decided to spend at most $$$T$$$ burles at the fair. However, he has some plan in mind for his path across the booths:  at first, he visits booth number $$$1$$$;  if he has enough burles to buy exactly one candy from the current booth, then he buys it immediately;  then he proceeds to the next booth in the clockwise order (regardless of if he bought a candy or not). Polycarp's money is finite, thus the process will end once he can no longer buy candy at any booth.Calculate the number of candies Polycarp will buy.

The first line contains two integers $$$n$$$ and $$$T$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le T \le 10^{18}$$$) — the number of booths at the fair and the initial amount of burles Polycarp has. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the price of the single candy at booth number $$$i$$$.

Print a single integer — the total number of candies Polycarp will buy.

NoteLet's consider the first example. Here are Polycarp's moves until he runs out of money:  Booth $$$1$$$, buys candy for $$$5$$$, $$$T = 33$$$;  Booth $$$2$$$, buys candy for $$$2$$$, $$$T = 31$$$;  Booth $$$3$$$, buys candy for $$$5$$$, $$$T = 26$$$;  Booth $$$1$$$, buys candy for $$$5$$$, $$$T = 21$$$;  Booth $$$2$$$, buys candy for $$$2$$$, $$$T = 19$$$;  Booth $$$3$$$, buys candy for $$$5$$$, $$$T = 14$$$;  Booth $$$1$$$, buys candy for $$$5$$$, $$$T = 9$$$;  Booth $$$2$$$, buys candy for $$$2$$$, $$$T = 7$$$;  Booth $$$3$$$, buys candy for $$$5$$$, $$$T = 2$$$;  Booth $$$1$$$, buys no candy, not enough money;  Booth $$$2$$$, buys candy for $$$2$$$, $$$T = 0$$$. No candy can be bought later. The total number of candies bought is $$$10$$$.In the second example he has $$$1$$$ burle left at the end of his path, no candy can be bought with this amount.

package main

// test input:
// 5 21
// 2 4 100 2 6
// output
// 6

// test input:
// 3 38
// 5 2 5
// ouput
// 10

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

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...) }

func sum(slice []int) uint64 {
	sum := uint64(0)
	for _, value := range slice {
		sum += uint64(value)
	}
	return sum
}

// return index INCLUDED
func binarySearch(targetSlic []int, T uint64) int {

	startIndex := 0
	endIndex := len(targetSlic) - 1

	for startIndex <= endIndex {
		// fmt.Printf("%v, %v\n", startIndex, endIndex)

		median := startIndex + (endIndex-startIndex)/2

		// fmt.Printf("sum: %v\n", sum(targetSlic[0:median]))
		if uint64(sum(targetSlic[0:median])) <= T {
			// fmt.Print("less")
			startIndex = median + 1
		} else {
			// fmt.Print("more")
			endIndex = median - 1
		}
	}

	return startIndex - 1
}

// Optimize using this, if couldn't pass tests
// func nextMaxIndex(slice []int) chan int {

// }

func solution(prices []int, T uint64) uint64 {
	min := prices[0]

	for _, val := range prices {
		// printf("min: %v\n", min)
		if val < min {
			min = val
		}
	}

	candies := uint64(0)

	s := uint64(sum(prices))
	// find s = sum(prices), if s < T, optimize, if not, exlude max, check s < T, repeat until s < T
	// break then min > T
	for s != 0 {
		// skip steps, if sum less then current balance
		if s <= T {
			candies += uint64(len(prices)) * (T / uint64(s))
			T %= uint64(s)
		} else {
			// Imitate walking threw candy market
			// FIXME: tmpCandies currenntly int32, which is
			// 16 bit for positive numbers
			// Actually, I'm not sure, math.MaxInt32 is 2147483647
			// ACTUALLY I AM STUPID
			// Integers stored as 1 bit for sign, and 31 bit for value,
			// I need to see wrong test again to make new theory
			tmpS, tmpT, tmpCandies := uint64(0), uint64(T), 0

			pricesPtr := prices[:0]
			for _, val := range prices {
				// could we buy candy?
				if uint64(val) <= tmpT {
					tmpS += uint64(val)
					tmpT -= uint64(val)
					tmpCandies++
					// we bought it, add to prices
					pricesPtr = append(pricesPtr, val)
				}
			}
			// printf("to exlude: %v\n", pricesPtr)
			candies += uint64(tmpCandies)
			prices = pricesPtr
			s = tmpS
			if tmpS <= T {
				T -= tmpS
			} else {
				break
			}
		}
	}

	return uint64(candies)
}

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	// printf("maxInt: %v\n", math.MaxUint64)
	var n int
	var T uint64
	scanf("%d %d", &n, &T)
	prices := make([]int, n)
	scanf("\n")
	for i := 0; i < n; i++ {
		scanf("%d", &prices[i])
	}
	printf("%v\n", solution(prices, T))
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	T := io.NextLong()
	A := io.NextLongArray(N)

	var candies int64
	for len(A) > 0 {
		var all int64
		for _, v := range A {
			all += v
		}

		candies += T / all * int64(len(A))
		T %= all

		stores := make([]int64, 0)
		for _, v := range A {
			if T < v {
				continue
			}
			T -= v
			stores = append(stores, v)
			candies++
		}
		A = stores
	}
	io.Println(candies)
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

var n int
var t int64

var a []int64

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &t)
	a = make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
	}

	result := int64(0)
	for t > 0 {
		n = len(a)
		s := int64(0)
		b := make([]int64, 0)
		c := int64(0)
		for i := 0; i < n; i++ {
			if t >= s+a[i] {
				s += a[i]
				b = append(b, a[i])
				c += 1
			}
		}
		if s == 0 {
			break
		}
		result += t / s * c
		t %= s
		a = b
	}
	fmt.Println(result)
}

package main

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

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...) }

func sum(slice []int) int {
	sum := 0
	for _, value := range slice {
		sum += value
	}
	return sum
}

// return index INCLUDED
func binarySearch(targetSlic []int, T uint64) int {

	startIndex := 0
	endIndex := len(targetSlic) - 1

	for startIndex <= endIndex {
		// fmt.Printf("%v, %v\n", startIndex, endIndex)

		median := startIndex + (endIndex-startIndex)/2

		// fmt.Printf("sum: %v\n", sum(targetSlic[0:median]))
		if uint64(sum(targetSlic[0:median])) <= T {
			// fmt.Print("less")
			startIndex = median + 1
		} else {
			// fmt.Print("more")
			endIndex = median - 1
		}
	}

	return startIndex - 1
}

// Optimize using this, if couldn't pass tests
// func nextMaxIndex(slice []int) chan int {

// }

func solution(prices []int, T uint64) uint64 {
	min, max := prices[0], prices[0]

	// sortedPrices := make([]int, len(prices))
	// copy(sortedPrices, prices)
	// sort.Ints(sortedPrices)
	// printf("sorted: %v\n", sortedPrices)

	for _, val := range prices {
		// printf("min: %v\n", min)
		if val < min {
			min = val
		}
		if val > max {
			max = val
		}
	}

	candies := uint64(0)

	s := uint64(sum(prices))
	// find s = sum(prices), if s < T, optimize, if not, exlude max, check s < T, repeat until s < T
	// break then min > T
	for s != 0 {
		// printf("candies: %v, prices: %v, T:%v\n", candies, prices, T)
		if uint64(s) <= T {
			candies += uint64(len(prices)) * (T / uint64(s))
			T %= uint64(s)
		} else {
			// Imitate walking threw candy market

			tmpS, tmpT, tmpCounter := uint64(0), uint64(T), 0

			slicePtr := prices[:0]
			for _, val := range prices {
				// could we buy candy?
				if uint64(val) <= tmpT {
					tmpS += uint64(val)
					tmpT -= uint64(val)
					tmpCounter++
					// we bought it, add to prices
					slicePtr = append(slicePtr, val)
				}
			}
			// printf("to exlude: %v\n", slicePtr)
			candies += uint64(tmpCounter)
			prices = slicePtr
			s = tmpS
			if tmpS <= T {
				T -= tmpS
			} else {
				break
			}
		}
	}

	return uint64(candies)
}

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	// test := []int{5, 2, 5}
	// printf("candies: %v\n", solution(test, 38))

	var n int
	var T uint64
	scanf("%d %d", &n, &T)
	prices := make([]int, n)
	scanf("\n")
	for i := 0; i < n; i++ {
		scanf("%d", &prices[i])
	}
	printf("%v\n", solution(prices, T))
}

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...) }

func solution(prices []int, T uint64) uint64 {
	min := prices[0]
	// printf("prices: %v\n", prices)
	// printf("min: %v\n", min)

	for _, val := range prices {
		// printf("min: %v\n", min)
		if val < min {
			min = val
		}
	}

	l := len(prices)
	counter, index := uint64(0), 0

	printf("min: %v\n", min)

	for uint64(min) <= T {
		// printf("counter: %v, index: %v, T:%v\n", counter, index, T)
		if uint64(prices[index]) > T {
			index = (index + 1) % l
			continue
		}
		T = T - uint64(prices[index])
		counter++
		index = (index + 1) % l
	}
	return counter
}

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n int
	var T uint64
	scanf("%d %d", &n, &T)
	prices := make([]int, n)
	scanf("\n")
	for i := 0; i < n; i++ {
		scanf("%d", &prices[i])
	}
	printf("%v\n", solution(prices, T))
}

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...) }

func solution(prices []int, T uint64) uint64 {
	min := prices[0]
	// printf("prices: %v\n", prices)
	// printf("min: %v\n", min)

	for _, val := range prices {
		// printf("min: %v\n", min)
		if val < min {
			min = val
		}
	}

	l := len(prices)
	counter, index := uint64(0), 0

	// printf("min: %v\n", min)

	for i := 0; i < 10; i++ {
		// printf("counter: %v, index: %v, T:%v\n", counter, index, T)
		if uint64(prices[index]) > T {
			index = (index + 1) % l
			continue
		}
		T = T - uint64(prices[index])
		counter++
		index = (index + 1) % l
	}
	return counter
}

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n int
	var T uint64
	scanf("%d %d", &n, &T)
	prices := make([]int, n)
	scanf("\n")
	for i := 0; i < n; i++ {
		scanf("%d", &prices[i])
	}
	printf("%v\n", solution(prices, T))
}

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...) }

func solution(prices []int, T uint64) uint64 {
	min := prices[0]
	// printf("prices: %v\n", prices)
	// printf("min: %v\n", min)

	for _, val := range prices {
		// printf("min: %v\n", min)
		if val < min {
			min = val
		}
	}

	l := len(prices)
	counter, index := uint64(0), 0

	// printf("min: %v\n", min)

	for uint64(min) < T {
		// printf("counter: %v, index: %v, T:%v\n", counter, index, T)
		if uint64(prices[index]) > T {
			index = (index + 1) % l
			continue
		}
		T = T - uint64(prices[index])
		counter++
		index = (index + 1) % l
	}
	return counter
}

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n int
	var T uint64
	scanf("%d %d", &n, &T)
	prices := make([]int, n)
	scanf("\n")
	for i := 0; i < n; i++ {
		scanf("%d", &prices[i])
	}
	printf("%v\n", solution(prices, T))
}


It's a walking tour day in SIS.Winter, so $$$t$$$ groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.Initially, some students are angry. Let's describe a group of students by a string of capital letters "A" and "P":   "A" corresponds to an angry student  "P" corresponds to a patient student Such string describes the row from the last to the first student.Every minute every angry student throws a snowball at the next student. Formally, if an angry student corresponds to the character with index $$$i$$$ in the string describing a group then they will throw a snowball at the student that corresponds to the character with index $$$i+1$$$ (students are given from the last to the first student). If the target student was not angry yet, they become angry. Even if the first (the rightmost in the string) student is angry, they don't throw a snowball since there is no one in front of them.Let's look at the first example test. The row initially looks like this: PPAP. Then, after a minute the only single angry student will throw a snowball at the student in front of them, and they also become angry: PPAA. After that, no more students will become angry.Your task is to help SIS.Winter teachers to determine the last moment a student becomes angry for every group.

The first line contains a single integer $$$t$$$ — the number of groups of students ($$$1 \le t \le 100$$$). The following $$$2t$$$ lines contain descriptions of groups of students. The description of the group starts with an integer $$$k_i$$$ ($$$1 \le k_i \le 100$$$) — the number of students in the group, followed by a string $$$s_i$$$, consisting of $$$k_i$$$ letters "A" and "P", which describes the $$$i$$$-th group of students.

For every group output single integer — the last moment a student becomes angry.

NoteIn the first test, after $$$1$$$ minute the state of students becomes PPAA. After that, no new angry students will appear.In the second tets, state of students in the first group is:   after $$$1$$$ minute — AAPAAPPAAPPP  after $$$2$$$ minutes — AAAAAAPAAAPP  after $$$3$$$ minutes — AAAAAAAAAAAP  after $$$4$$$ minutes all $$$12$$$ students are angry In the second group after $$$1$$$ minute, all students are angry.

package main

import "fmt"

type group struct {
	nStuds int
	line string
}

func main() {
	var gCount int
	fmt.Scanln(&gCount)
	var g group
	for i := 0; i < gCount; i++ {
		fmt.Scanln(&g.nStuds)
		fmt.Scanln(&g.line)

		mp := 0
		c := 0
		pa := false
		for j := 0; j < g.nStuds; j++ {
			if pa {
				if g.line[j] == 'P' {
					c++
				} else {
					if c > mp {
						mp = c
					}
					c = 0
				}
			} else if !pa && g.line[j] == 'A' {
				pa = true
			}
		}

		if c > mp {
			mp = c
		}

		fmt.Println(mp)
	}
}

package main

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

func main() {
	var t, n int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &s)
		la := -1
		a := -1
		max := 0
		for i, v := range s {
			if v == 'A' {
				a = i
			}
			if la != -1 && max < a-la-1 {
				max = a - la - 1
			}
			la = a
		}
		if la != -1 && max < n-la-1 {
			max = n - la - 1
		}
		fmt.Println(max)
	}
}

package main

import (
	"fmt"
)

func numMins(a string, b int) int {
	mins := -1
	condition := 1
	for condition == 1 {
		condition = 0
		for i := 0; i < b-1; i++ {
			if a[i] == 'A' && a[i+1] == 'P' {
				condition = 1
				a = a[:i+1] + string('A') + a[i+2:]
				i = i + 1
			}
		}
		mins++

	}
	return mins

}

func main() {
	var numOperations, numPupils int
	var stringPupils string
	fmt.Scan(&numOperations)
	for i := 0; i < numOperations; i++ {
		fmt.Scan(&numPupils)
		fmt.Scan(&stringPupils)
		fmt.Println(numMins(stringPupils, numPupils))

	}

}

package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var t, k int
	var s string
	fmt.Scan(&t)
	answers := []int{}
	for i := 0; i < t; i++ {
		fmt.Scan(&k, &s)
		if strings.Contains(s, "A") {
			passives := strings.Split(s, "A")[1:]
			lens := getStrArrElementsLen(passives)
			sort.Ints(lens)
			answers = append(answers, lens[len(lens)-1])
		} else {
			answers = append(answers, 0)
		}
	}
	for i := 0; i < t; i++ {
		fmt.Println(answers[i])
	}
}

func getStrArrElementsLen(strs []string) []int {
	lens := make([]int, len(strs), 2*len(strs))
	for i, str := range strs {
		lens[i] = len(str)
	}
	return lens
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		s := ""
		fmt.Fscanf(in, "%s\n", &s)
		ans := 0
		cur := 0
		for len(s) > 0 {
			if s[0] == 'P' {
				s = s[1:]
			} else {
				s = s[1:]
				cur = 0
				for len(s) > 0 && s[0] == 'P' {
					cur++
					s = s[1:]
				}
				if cur > ans {
					ans = cur
				}
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	t := readInt()
	for i := 0; i < t; i++ {
		solve(readInt(), readString())
	}
}

func solve(k int, s string) {
	ps := strings.Split(s, "A")
	if len(ps) == 0 {
		fmt.Println(0)
		return
	}

	var maxi int
	for i := 1; i < len(ps); i++ {
		maxi = max(len(ps[i]), maxi)
	}
	fmt.Println(maxi)
}

package main

import "fmt"

func main() {
	var numberOfStudents int
	_, _ = fmt.Scan(&numberOfStudents)

	for i := 0; i < numberOfStudents; i++ {
		var length int
		_, _ = fmt.Scan(&length)
		var input string
		_, _ = fmt.Scan(&input)
		current := 0
		max := 0
		flag := false
		for j := 0; j < length; j++ {
			if input[j] == 'A' {
				flag = true
			}
			if input[j] == 'P' && flag {
				current++
			} else {
				if max < current {
					max = current
				}
				current = 0
			}
		}
		if max < current {
			max = current
		}
		fmt.Println(max)
	}

}

package main

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

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

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

	is := func() string {
		sc.Scan()
		return sc.Text()
	}

	for t := ii(); t > 0; t-- {
		n := ii()
		s := is()

		m, c := 0, 0
		beg := true
		for i := 0; i < n; i++ {
			if s[i] == 'A' {
				beg = false
				if m < c {
					m = c
				}
				c = 0
			} else {
				if !beg {
					c++
				}
			}
		}

		if m < c {
			m = c
		}

		fmt.Println(m)
	}
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func MaxLenghtOfContiniousChar(s string, c string, from int) int {
	maxLength := 0
	currLength := 0

	for i := from; i < len(s); i += 1 {
		if string(s[i]) == c {
			currLength += 1
		}
		if currLength > maxLength {
			maxLength = currLength
		}
		if string(s[i]) != c {
			currLength = 0
		}
	}

	return maxLength
}

func ProcessInputStudents() int {
	var students string
	var count int
	var startFrom int

	fmt.Fscan(os.Stdin, &count)
	fmt.Fscan(os.Stdin, &students)

	startFrom = strings.Index(students, "A")

	if startFrom == -1 {
		return 0
	}

	return MaxLenghtOfContiniousChar(students, "P", startFrom)
}

func main() {
	var groupsCount int
	var lastMoments []int

	fmt.Fscan(os.Stdin, &groupsCount)

	lastMoments = make([]int, groupsCount)

	for i := 0; i < groupsCount; i += 1 {
		lastMoments[i] = ProcessInputStudents()
	}

	for i := 0; i < groupsCount; i += 1 {
		fmt.Println(lastMoments[i])
	}
}

package main

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

// Complete the climbingLeaderboard function below.
func climbingLeaderboard(scores []int32, alice []int32) []int32 {
	distinct := make([]int32, 0)
	prev := int32(0)
	for _, v := range scores {
		if v == prev {
			continue
		}
		distinct = append(distinct, v)
		prev = v
	}
	ret := make([]int32, len(alice))
	for i, v := range alice {
		ret[i] = insertIndex(distinct, v) + 1
	}
	return ret
}

func insertIndex(arr []int32, v int32) int32 {
	l, r := int32(0), int32(len(arr))
	for l < r {
		m := l + (r-l)/2
		if arr[m] == v {
			return m
		}
		if arr[m] < v {
			r = m
		} else {
			l = m + 1
		}
	}
	return l
}

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

	t := readInt(reader)

	for ; t > 0; t-- {
		readLine(reader)

		line := readLine(reader)

		last := 101
		ret := 0
		for i, ch := range line {
			if ch == 'A' {
				if i-last-1 > ret {
					ret = i - last - 1
				}
				last = i
			}
		}

		if len(line)-last-1 > ret {
			ret = len(line) - last - 1
		}
		fmt.Println(ret)
	}
}

func readInt(reader *bufio.Reader) int {
	v, err := strconv.ParseInt(readLine(reader), 10, 32)
	checkError(err)
	return int(v)
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')

	if err == io.EOF {
		return str
	} else if err != nil {
		panic(err)
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!
package main

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

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := PrintlnInts(X...)

/*******************************************************************/

func main() {
	for t := ReadInt(); t > 0; t-- {
		k := ReadInt()
		s := ReadString()
		ans, cur := 0, 0
		for k--; k >= 0; k-- {
			if s[k] == 'A' {
				if ans < cur {
					ans = cur
				}
				cur = 0
			} else {
				cur++
			}
		}
		fmt.Println(ans)
	}
}

/*********** Math ***********/
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func max(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

func _gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return _gcd(b, a%b)
}

func gcd(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	gcd := args[0]
	for i := 1; i < len(args); i++ {
		gcd = _gcd(gcd, args[i])
	}
	return gcd
}

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return readInt()
}
func ReadInt2() (int, int) {
	return readInt(), readInt()
}
func ReadInt3() (int, int, int) {
	return readInt(), readInt(), readInt()
}
func ReadInt4() (int, int, int, int) {
	return readInt(), readInt(), readInt(), readInt()
}

func readInt_64() int64 {
	return readIntNbits(64)
}

func ReadInt2_64() (int64, int64) {
	return readInt_64(), readInt_64()
}

func ReadInt3_64() (int64, int64, int64) {
	return readInt_64(), readInt_64(), readInt_64()
}

func readInt() int {
	return int(readIntNbits(32))
}

func readIntNbits(n int) int64 {
	i, err := strconv.ParseInt(ReadString(), 0, n)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

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

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

// PrintIntsLine returns integers string delimited by a space.
func PrintlnInts(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

package main

import "fmt"
import "os"
import "bufio"
//~ import "strings"
import "strconv"

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    capacity := 5000 * 1024
    scanner.Buffer(make([]byte, capacity), capacity)
    scanner.Scan()
    line := scanner.Text()
    t, _ := strconv.Atoi(line)
    for i := 0; i < t; i++ {
        scanner.Scan()
        line = scanner.Text()
        //~ parts := strings.Split(line, " ")
        //~ n, _ := strconv.Atoi(parts[0])

        scanner.Scan()
        line = scanner.Text()
        //~ fmt.Println("case", n, line)

        changed := true
        steps := -1
        for changed {
            steps++
            changed = false
            for j := len(line) - 1; j >= 1; j-- {
                if line[j] == 'P' && line[j - 1] == 'A' {
                    line = line[:j] + "A" + line[j + 1:]
                    changed = true
                }
            }
        }

        //~ fmt.Println(steps, line)
        fmt.Println(steps)
    }
}

package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

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

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcdll(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcdll(b, a%b)
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	N := readi()
	for i := 0; i < N; i++ {
		_ = readi()
		A := readb()
		println(solve(A))
	}

}

func solve(A []byte) int {
	var ans, cnt int
	for i := len(A) - 1; 0 <= i; i-- {
		if A[i] == 'P' {
			cnt++
		} else {
			ans = max(ans, cnt)
			cnt = 0
		}
	}
	return ans
}

package main

import (
	"fmt"
)

func max(x, y uint8) uint8 {
	if x > y {
		return x
	}
	return y
}

func main() {
	var t uint8
	fmt.Scan(&t)
	for t > 0 {
		var n uint8
		fmt.Scan(&n)
		var s string
		fmt.Scan(&s)
		var ans, count uint8
		start := false
		for _, c := range s {
			if c == 'A' {
				ans = max(ans, count)
				count = 0
				start = true
			} else {
				if start {
					count ++
				}
			}
			//fmt.Println(c, ans, count)
		}
		fmt.Println(max(ans, count))
		t--
	}
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"sync"
)

func main() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		s := ReadString()

		foundA := false
		l, r := -1, -1
		minI, maxI := 0, 0

		for i := 0; i < n; i++ {
			if s[i] == 'A' {
				l, r = i, i
				foundA = true
				continue
			}
			if !foundA {
				continue
			}

			if s[i] == 'P' {
				if s[i-1] == 'P' {
					r = i
				} else {
					l, r = i, i
				}

				if r-l+1 > maxI-minI {
					minI = l
					maxI = r
				}
			}
		}
		if foundA && maxI > 0 && minI > 0 {
			out <- strconv.Itoa((maxI - minI + 1))
		} else {
			out <- strconv.Itoa(0)
		}
	}
	close(out)
	outWg.Wait()
}

/*********************** utility ***********************/

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	// set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

		for line := range out {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ReadString() string {
	in.Scan()
	return in.Text()
}

func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}

func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.Atoi(intStr)
	return i
}

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

package main

import (
	"fmt"
)

func solve() {
    var (
        n int
        s string
    )
    fmt.Scan(&n, &s)
    var ans int = 0
    var cur int = 0
    var i int
    for i = 0; i < n; i++ {
    	if s[i] == 'A' {
    		break
    	}
    }
    for ; i < n; i++ {
    	if s[i] == 'A' {
    		cur = 0
    	} else {
    		cur++
    	}
    	if cur > ans {
    		ans = cur
    	}
    }
    fmt.Println(ans)
}

func main() {
    var t int
    fmt.Scan(&t)
    for ; t > 0; t-- {
        solve()
    }
}

package main

import "fmt"

func main() {
	groupsCnt := 0
	fmt.Scanf("%d\n", &groupsCnt)

	var group string
	var count int
	var maxCount int
	var isA bool

	for i := 0; i < groupsCnt; i++ {
		count = 0
		maxCount = 0
		isA = false
		fmt.Scanf("%d\n%s\n", new(uint32), &group)
		for _, r := range group {
			switch r {
			case 'A':
				if count > maxCount {maxCount = count}
				count = 0
				if !isA {
					maxCount = 0
					count = 0
					isA = true
				}
			case 'P':
				count++
			}
		}
		if isA && count > maxCount {maxCount = count}
		fmt.Printf("%d\n", maxCount)
	}
}

package main

import (
    "fmt"
    "strings"
    )
func main(){
    var n, l int
    fmt.Scan(&n)
    for j := 0; j < n ;j++ {
        var s string
        fmt.Scan(&l, &s)
        a := strings.Split(s,"A")
        m := 0
        for i, x := range a {
            if i != 0 && len(x) > m {
                m = len(x)
            }
        }
        fmt.Println(m)
    }

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var numCases, k int
	var group string
	fmt.Fscanf(reader, "%d\n", &numCases)
	for tcase := 1; tcase <= numCases; tcase++ {
		fmt.Fscanf(reader, "%d\n", &k)
		fmt.Fscanf(reader, "%s\n", &group)
		count := 0
		gBytes := []byte(group)
		prev := group
		cur := group
		for {
			idx := 0
			for idx < k-1 {
				if gBytes[idx] == 'A' && gBytes[idx+1] == 'P' {
					gBytes[idx+1] = 'A'
					idx = idx + 2
				} else {
					idx += 1
				}
			}
			cur = string(gBytes)
			if prev == cur {
				break
			} else {
				prev = cur
				count += 1
			}
		}
		fmt.Fprintf(writer, "%d\n", count)
	}
}

package main

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

func main() {
	var t, n int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &s)
		aidx := 0
		for i, v := range s {
			if v == 'A' {
				aidx = i
			}
		}
		fmt.Println(n - aidx - 1)
	}
}

package main

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

func main() {
	var t, n int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &s)
		aidx := n - 1
		for i, v := range s {
			if v == 'A' {
				aidx = i
			}
		}
		fmt.Println(n - aidx - 1)
	}
}

package main

import "fmt"

func main() {
	var numberOfStudents int

	_, _ = fmt.Scan(&numberOfStudents)
	for i := 0; i < numberOfStudents; i++ {
	    var length int
	    _, _ = fmt.Scan(&length)
		var input string
		_, _ = fmt.Scan(&input)
		for j, _ := range input {
			if input[length-j-1] == 'A' {
				fmt.Println(j)
				break
			}
		}
	}

}

package main

import "fmt"

func main() {
	var numberOfStudents int

	_, _ = fmt.Scan(&numberOfStudents)
	for i := 0; i < numberOfStudents; i++ {
	    var length int
	    _, _ = fmt.Scan(&length)
		var input string
		_, _ = fmt.Scan(&input)
		current := 0
		max := 0
		flag := false
		for j, _ := range input {
		    if input[j] == 'A' {
		        flag = true
		    }
			if input[j] == 'P' && flag{
				current++
			} else {
			    if max < current {
			        max = current
			        current = 0
			    }
			}
		}
		 if max < current {
			        max = current
			    }
		fmt.Println(max)
	}

}

package main

import "fmt"

func main() {
	var numberOfStudents int

	_, _ = fmt.Scan(&numberOfStudents)
	for i := 0; i < numberOfStudents; i++ {
		var input string
		_, _ = fmt.Scan(&input)
		length := len(input)
		for j, _ := range input {
			if input[length-j-1] == 'A' {
				fmt.Println(j)
				break
			}
		}
	}

}

package main

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

// Complete the climbingLeaderboard function below.
func climbingLeaderboard(scores []int32, alice []int32) []int32 {
	distinct := make([]int32, 0)
	prev := int32(0)
	for _, v := range scores {
		if v == prev {
			continue
		}
		distinct = append(distinct, v)
		prev = v
	}
	ret := make([]int32, len(alice))
	for i, v := range alice {
		ret[i] = insertIndex(distinct, v) + 1
	}
	return ret
}

func insertIndex(arr []int32, v int32) int32 {
	l, r := int32(0), int32(len(arr))
	for l < r {
		m := l + (r-l)/2
		if arr[m] == v {
			return m
		}
		if arr[m] < v {
			r = m
		} else {
			l = m + 1
		}
	}
	return l
}

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

	t := readInt(reader)

	for ; t > 0; t-- {
		readLine(reader)

		line := readLine(reader)

		last := 101
		ret := 0
		for i, ch := range line {
			if ch == 'A' {
				if i-last > ret {
					ret = i - last
				}
				last = i
			}
		}

		if len(line)-last-1 > ret {
			ret = len(line) - last - 1
		}
		fmt.Println(ret)
	}
}

func readInt(reader *bufio.Reader) int {
	v, err := strconv.ParseInt(readLine(reader), 10, 32)
	checkError(err)
	return int(v)
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')

	if err == io.EOF {
		return str
	} else if err != nil {
		panic(err)
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

import (
    "fmt"
    "strings"
    )
func main(){
    var n, l int
    for j := 0; j < n ;j++ {
        var s string
        fmt.Scan(&l, &s)
        a := strings.Split(s,"A")
        m := 0
        for i, x := range a {
            if i != 0 && len(x) > m {
                m = len(x)
            }
        }
        fmt.Println(m)
    }

}

package main

import (
    "fmt"
    "strings"
    )
func main(){
    var s string
    fmt.Scan(&s)
    a := strings.Split(s,"A")
    m := 0
    for i, x := range a {
        if i != 0 && len(x) > m {
            m = len(x)
        }
    }
    fmt.Println(m)

}


You are given $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$. Find the maximum value of $$$max(a_l, a_{l + 1}, \ldots, a_r) \cdot min(a_l, a_{l + 1}, \ldots, a_r)$$$ over all pairs $$$(l, r)$$$ of integers for which $$$1 \le l < r \le n$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10\,000$$$)  — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^6$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

For each test case, print a single integer  — the maximum possible value of the product from the statement.

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	tc := readInt(in)

	for i := 0; i < tc; i++ {
        n := readInt(in)
        arr := readArrInt64(in)
        max := arr[0]
        for j := 0; j < n-1; j++ {
            if arr[j]*arr[j+1] > max {
                max = arr[j]*arr[j+1]
            }
        }
        fmt.Println(max)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		largest:=0
		for j:=1;j<n;j++{
			if largest < int(list[j])*int(list[j-1]) {
				largest= int(list[j])*int(list[j-1])
			}
		}
		fmt.Fprintln(out,largest)
	}
}

package main

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

func solve(r *bufio.Reader) {
	var n int
	fmt.Fscan(r, &n)
	var curr, prev int64
	max := int64(0)
	fmt.Fscan(r, &curr)
	for i := 1; i < n; i++ {
		prev = curr
		fmt.Fscan(r, &curr)
		if curr*prev > max {
			max = curr * prev
		}
	}
	fmt.Println(max)
}
func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	for i := 0; i < n; i++ {
		solve(r)
	}
}

package main

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

type CF1554A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1554A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1554A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1554A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1554A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1554A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1554A
Date: 8/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1554/A
Problem: CF1554A
**/
func (in *CF1554A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt()
		arr := make([]int64, n)
		sol := int64(0)
		for i := 0; i < n; i++ {
    		arr[i] = in.NextInt64()
    		if i > 0 {
				sol = Max(sol, arr[i]*arr[i-1])
			}
		}
		fmt.Println(sol)
	}
}

func Max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func NewCF1554A(r *bufio.Reader) *CF1554A {
	return &CF1554A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1554A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int64 {
	var x int64
	for i := 0; i < n-1; i++ {
		k := int64(a[i]) * int64(a[i+1])
		if x < k {
			x = k
		}
	}
	return x
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int
	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscanf(r, "%d\n", &n)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(r, "%d", &arr[i])
		}
		fmt.Fscanf(r, "\n")

		res := int64(0)
		for i := 0; i < n-1; i++ {
			x := int64(arr[i]) * int64(arr[i+1])
			if x > res {
				res = x
			}
		}

		fmt.Println(res)
	}
}

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			n := iost.GetNextInt()
			var p, ret int64
			for i := 0; i < n; i++ {
				a := iost.GetNextInt64()
				if i != 0 {
					v := a * p
					if ret < v {
						ret = v
					}
				}
				p = a
			}
			iost.Println(ret)
		}()
	}
}

package main

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

func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	solve := func() {
		var n int
		var ans int64
		Fscan(in, &n)
		a := make([]int64, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		for i := 1; i < n; i++ {
			ans = max(ans, a[i]*a[i-1])
		}
		Fprintln(out, ans)
	}
	var T int
	Fscan(in, &T)
	for i := 0; i < T; i++ {
		solve()
	}
}

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

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {

		var n int
		fmt.Fscan(input, &n)

		ARRAY := make([]int64, n)
		var biggest int64
		fmt.Fscan(input, &ARRAY[0])
		for i := 1; i < n; i++ {
			fmt.Fscan(input, &ARRAY[i])
			q := ARRAY[i] * ARRAY[i-1]
			if q > biggest {
				biggest = q
			}
		}
		fmt.Println(biggest)

	}

}

package main

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

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}

func main() {
	defer out.Flush()

	var (
		n, t int
	)
	fmt.Fscanf(in, "%d", &t)

	for t > 0 {
		t--
		fmt.Fscan(in, &n)

		s := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &s[i])
		}
		var ans int64
		for i := 1; i < n; i++ {
			if s[i]*s[i-1] > ans {
				ans = s[i] * s[i-1]
			}
		}
		printf("%d\n", ans)
	}

}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(r, &n)

		a := make([]int64, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		solve(a, n)
	}
}

func solve(a []int64, n int) {
	//1 <= l < r <= n
	//6 6 1 4 8 3 6 1 2 7
	//min * max
	//

	var ans int64

	for j := 0; j < n; j++ {
		var d int64
		if j > 0 {
			if a[j - 1] <= a[j] {
				d = a[j - 1] * a[j]
			}
		}
		if j < n - 1 {
			if a[j] >= a[j + 1] {
				d = max(d, a[j] * a[j + 1])
			}
		}

		ans = max(ans, d)
	}

	fmt.Println(ans)
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	tc := readInt(in)

	for i := 0; i < tc; i++ {
        n := readInt(in)
        arr := readArrInt64(in)
        max := arr[0]
        pos := 0
        for j, a := range arr {
            if a > max {
                max = a
                pos = j
            }
        }
        if pos == n-1 {
            fmt.Println(max*arr[pos-1])
        } else if pos == 0 {
            fmt.Println(max*arr[pos+1])
        } else {
            prev := max*arr[pos-1]
            forw := max*arr[pos+1]
            if prev > forw {
                fmt.Println(prev)
            } else {
                fmt.Println(forw)
            }
        }
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

import (
    "fmt"
)

func main() {
    var tC int
    var val int
    fmt.Scanln(&tC)

    for i := 0; i < tC; i++ {
        var length int
        fmt.Scan(&length)

        fmt.Scan(&val)
        max := val
        pos := 0
        arr := make([]int, 0)
        arr = append(arr, val)
        for j := 1; j < length; j++ {
            fmt.Scan(&val)
            arr = append(arr, val)
            if val > max {
                max = val
                pos = j
            }
        }
        if pos == length-1 {
            fmt.Println(max*arr[pos-1])
        } else if pos == 0 {
            fmt.Println(max*arr[pos+1])
        } else {
            prev := max*arr[pos-1]
            forw := max*arr[pos+1]
            if prev > forw {
                fmt.Println(prev)
            } else {
                fmt.Println(forw)
            }
        }
    }
}