The robot is located on a checkered rectangular board of size $$$n \times m$$$ ($$$n$$$ rows, $$$m$$$ columns). The rows in the board are numbered from $$$1$$$ to $$$n$$$ from top to bottom, and the columns — from $$$1$$$ to $$$m$$$ from left to right.The robot is able to move from the current cell to one of the four cells adjacent by side.Each cell has one of the symbols 'L', 'R', 'D' or 'U' written on it, indicating the direction in which the robot will move when it gets in that cell — left, right, down or up, respectively.The robot can start its movement in any cell. He then moves to the adjacent square in the direction indicated on the current square in one move.   If the robot moves beyond the edge of the board, it falls and breaks.  If the robot appears in the cell it already visited before, it breaks (it stops and doesn't move anymore). Robot can choose any cell as the starting cell. Its goal is to make the maximum number of steps before it breaks or stops.Determine from which square the robot should start its movement in order to execute as many commands as possible. A command is considered successfully completed if the robot has moved from the square on which that command was written (it does not matter whether to another square or beyond the edge of the board).

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10000$$$) — the number of test cases in the test. Each test case's description is preceded by a blank line. Next is a line that contains integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2000$$$; $$$1 \le m \le 2000$$$) — the height and width of the board. This line followed by $$$n$$$ lines, the $$$i$$$-th of which describes the $$$i$$$-th line of the board. Each of them is exactly $$$m$$$ letters long and consists of symbols 'L', 'R', 'D' and 'U'. It is guaranteed that the sum of sizes of all boards in the input does not exceed $$$4\cdot10^6$$$.

For each test case, output three integers $$$r$$$, $$$c$$$ and $$$d$$$ ($$$1 \le r \le n$$$; $$$1 \le c \le m$$$; $$$d \ge 0$$$), which denote that the robot should start moving from cell $$$(r, c)$$$ to make the maximum number of moves $$$d$$$. If there are several answers, output any of them.

7

1 1
R

1 3
RRL

2 2
DL
RU

2 2
UD
RU

3 2
DL
UL
RU

4 4
RRRD
RUUD
URUD
ULLR

4 4
DDLU
RDDU
UUUU
RDLD

package main

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

func die(v ...interface{}) {
	_, _, line, _ := runtime.Caller(1)
	fmt.Printf("die line %d: %v\n", line, v)
	os.Exit(-1)
}

func check(b bool) {
	if !b {
		_, _, line, _ := runtime.Caller(1)
		fmt.Printf("check failed line %d\n", line)
		os.Exit(-1)
	}
}

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

type IntHeap []int

func (h IntHeap) Len() int            { return len(h) }
func (h IntHeap) Less(i, j int) bool  { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *IntHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

const (
	INIT = -1
)

var (
	n    int
	m    int
	adj  []int
	doom int
	d    []int
)

func at(i, j int) int {
	return i*m + j
}

// Tricks:
//   -ive distance for the current s
//   use path instead of p[u] to backtrack
//   subtract depth at cycle from total depth
func dist(s int) int {
	if d[s] != 0 {
		return d[s]
	}

	path := &IntHeap{}
	u := s
	depth := -1
	for u != doom && d[u] == 0 {
		d[u] = depth
		depth--
		path.Push(u)

		u = adj[u]
	}

	l := 1
	if u != doom {
		if d[u] < 0 { // cycle
			cycle := d[u] - depth // total depth - depth at start of cycle
			for i := 0; i < cycle; i++ {
				v := path.Pop().(int)
				d[v] = cycle
			}
		}
		l += d[u] // either start of cycle or other s path
	}

	for path.Len() > 0 {
		v := path.Pop().(int)
		d[v] = l
		l++
	}

	return d[s]
}

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

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

	for ; tc > 0; tc-- {

		fmt.Fscan(r, &n, &m)
		adj = make([]int, n*m+1)
		doom = n * m

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

			for j := 0; j < m; j++ {
				ni := i
				nj := j
				switch s[j] {
				case 'L':
					nj--
				case 'R':
					nj++
				case 'U':
					ni--
				case 'D':
					ni++
				}
				if ni < 0 || ni >= n || nj < 0 || nj >= m {
					adj[at(i, j)] = doom
				} else {
					adj[at(i, j)] = at(ni, nj)
				}
			}
		}

		d = make([]int, n*m+1)

		best := 0
		ans := INIT
		for u := 0; u < n*m; u++ {
			rv := dist(u)
			if best < rv {
				best = rv
				ans = u
			}
		}

		fmt.Printf("%d %d %d\n", ans/m+1, ans%m+1, best)

	}
}

package main

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

func die(v ...interface{}) {
	_, _, line, _ := runtime.Caller(1)
	fmt.Printf("die line %d: %v\n", line, v)
	os.Exit(-1)
}

func check(b bool) {
	if !b {
		_, _, line, _ := runtime.Caller(1)
		fmt.Printf("check failed line %d\n", line)
		os.Exit(-1)
	}
}

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

type IntHeap []int

func (h IntHeap) Len() int            { return len(h) }
func (h IntHeap) Less(i, j int) bool  { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *IntHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

const (
	INIT = -1
)

var (
	n    int
	m    int
	adj  []int
	doom int
	d    []int
)

func at(i, j int) int {
	return i*m + j
}

// Tricks:
//   -ive distance for the current s
//   use path instead of p[u] to backtrack
//   subtract depth at cycle from total depth
func dist(s int) int {
	if d[s] != 0 {
		return d[s]
	}

	path := IntHeap{}
	u := s
	depth := -1
	for u != doom && d[u] == 0 {
		d[u] = depth
		depth--
		path.Push(u)

		u = adj[u]
	}

	l := 1
	if u != doom {
		if d[u] < 0 { // cycle
			cycle := d[u] - depth // total depth - depth at start of cycle
			for i := 0; i < cycle; i++ {
				v := path.Pop().(int)
				d[v] = cycle
			}
		}
		l += d[u] // either start of cycle or other s path
	}

	for len(path) > 0 {
		v := path.Pop().(int)
		d[v] = l
		l++
	}

	return d[s]
}

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

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

	for ; tc > 0; tc-- {

		fmt.Fscan(r, &n, &m)
		adj = make([]int, n*m+1)
		doom = n * m

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

			for j := 0; j < m; j++ {
				ni := i
				nj := j
				switch s[j] {
				case 'L':
					nj--
				case 'R':
					nj++
				case 'U':
					ni--
				case 'D':
					ni++
				}
				if ni < 0 || ni >= n || nj < 0 || nj >= m {
					adj[at(i, j)] = doom
				} else {
					adj[at(i, j)] = at(ni, nj)
				}
			}
		}

		d = make([]int, n*m+1)

		best := 0
		ans := INIT
		for u := 0; u < n*m; u++ {
			rv := dist(u)
			if best < rv {
				best = rv
				ans = u
			}
		}

		fmt.Printf("%d %d %d\n", ans/m+1, ans%m+1, best)

	}
}

package main

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

func die(v ...interface{}) {
	_, _, line, _ := runtime.Caller(1)
	fmt.Printf("die line %d: %v\n", line, v)
	os.Exit(-1)
}

func check(b bool) {
	if !b {
		_, _, line, _ := runtime.Caller(1)
		fmt.Printf("check failed line %d\n", line)
		os.Exit(-1)
	}
}

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

type IntHeap []int

func (h IntHeap) Len() int            { return len(h) }
func (h IntHeap) Less(i, j int) bool  { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *IntHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

type vi []int

func (h *vi) pop() int {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

const (
	INIT = -1
)

var (
	n    int
	m    int
	adj  []int
	doom int
	d    []int
)

func at(i, j int) int {
	return i*m + j
}

// Tricks:
//   -ive distance for the current s
//   use path instead of p[u] to backtrack
//   subtract depth at cycle from total depth
func dist(s int) int {
	if d[s] != 0 {
		return d[s]
	}

	path := vi{}
	u := s
	depth := -1
	for u != doom && d[u] == 0 {
		d[u] = depth
		depth--
		path = append(path, u)

		u = adj[u]
	}

	l := 1
	if u != doom {
		if d[u] < 0 { // cycle
			cycle := d[u] - depth // total depth - depth at start of cycle
			for i := 0; i < cycle; i++ {
				v := path.pop()
				d[v] = cycle
			}
		}
		l += d[u] // either start of cycle or other s path
	}

	for len(path) > 0 {
		v := path.pop()
		d[v] = l
		l++
	}

	return d[s]
}

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

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

	for ; tc > 0; tc-- {

		fmt.Fscan(r, &n, &m)
		adj = make([]int, n*m+1)
		doom = n * m

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

			for j := 0; j < m; j++ {
				ni := i
				nj := j
				switch s[j] {
				case 'L':
					nj--
				case 'R':
					nj++
				case 'U':
					ni--
				case 'D':
					ni++
				}
				if ni < 0 || ni >= n || nj < 0 || nj >= m {
					adj[at(i, j)] = doom
				} else {
					adj[at(i, j)] = at(ni, nj)
				}
			}
		}

		d = make([]int, n*m+1)

		best := 0
		ans := INIT
		for u := 0; u < n*m; u++ {
			rv := dist(u)
			if best < rv {
				best = rv
				ans = u
			}
		}

		fmt.Printf("%d %d %d\n", ans/m+1, ans%m+1, best)

	}
}


On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost ai Egyptian pounds. If Sagheer buys k items with indices x1, x2, ..., xk, then the cost of item xj is axj + xj·k for 1 ≤ j ≤ k. In other words, the cost of an item is equal to its base cost in addition to its index multiplied by the factor k.Sagheer wants to buy as many souvenirs as possible without paying more than S Egyptian pounds. Note that he cannot buy a souvenir more than once. If there are many ways to maximize the number of souvenirs, he will choose the way that will minimize the total cost. Can you help him with this task?

The first line contains two integers n and S (1 ≤ n ≤ 105 and 1 ≤ S ≤ 109) — the number of souvenirs in the market and Sagheer's budget. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the base costs of the souvenirs.

On a single line, print two integers k, T — the maximum number of souvenirs Sagheer can buy and the minimum total cost to buy these k souvenirs.

NoteIn the first example, he cannot take the three items because they will cost him [5, 9, 14] with total cost 28. If he decides to take only two items, then the costs will be [4, 7, 11]. So he can afford the first and second items.In the second example, he can buy all items as they will cost him [5, 10, 17, 22].In the third example, there is only one souvenir in the market which will cost him 8 pounds, so he cannot buy it.

package main

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

func solve() {
	n := readInt()
	s := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	lo := 1
	hi := n
	ans := 0
	T := 0
	for lo <= hi {
		k := (lo + hi) / 2
		t := isOk(k, a, s)
		if t > 0 {
			lo = k + 1
			if ans < k {
				ans = k
				T = t
			}
		} else {
			hi = k - 1
		}
	}
	fmt.Println(ans, T)
}

func isOk(k int, a []int, s int) int {
	b := make([]int, 0)
	maxSum := int64(s)
	maxK := int64(k)
	for i := 0; i < len(a); i++ {
		v := int64(a[i]) + maxK*int64(i+1)
		if v <= maxSum {
			b = append(b, int(v))
		}
	}
	if len(b) < k {
		return 0
	}
	sort.Ints(b)
	sum := 0
	for i := 0; i < k; i++ {
		sum += b[i]
		if sum > s {
			return 0
		}
	}
	return sum
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

package main

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

func Init() {
}

func Solve(io *FastIO) {
    N := io.NextInt()
    S := io.NextLong()
    A := io.NextLongArrayOffset(N, 1)

    L := 1
    R := N
    good := 0
    price := int64(0)
    for L <= R {
        M := (L + R) >> 1
        costs := MakeCosts(A, M)
        if cost, ok := CanPurchase(costs, M, S); ok {
            good = M
            price = cost
            L = M + 1
        } else {
            R = M - 1
        }
    }
    io.Println(good, price)
}

func MakeCosts(A []int64, K int) []int64 {
    costs := make([]int64, len(A))
    for i := 1; i < len(A); i++ {
        costs[i] = A[i] + (int64(K) * int64(i))
    }
    return costs
}

func CanPurchase(costs []int64, K int, S int64) (int64, bool) {
    sort.Sort(SortInt64(costs[1:]))
    sum := int64(0)
    for i := 1; i <= K; i++ {
        sum += costs[i]
    }
    return sum, sum <= S
}

type SortInt64 []int64

func (s SortInt64) Len() int {
    return len(s)
}

func (s SortInt64) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

func (s SortInt64) Less(i, j int) bool {
    return s[i] < s[j]
}

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"
	"sort"
	"strconv"
)

func solve() {
	n := readInt()
	s := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	lo := 0
	hi := n
	ans := 0
	T := 0
	for lo <= hi {
		k := (lo + hi) / 2
		t := isOk(k, a, s)
		if t > 0 {
			lo = k + 1
			ans = k
			T = t
		} else {
			hi = k - 1
		}
	}
	fmt.Println(ans, T)
}

func isOk(k int, a []int, s int) int {
	b := make([]int, 0)
	for i := 0; i < len(a); i++ {
		v := int64(a[i]) + int64(k)*int64(i+1)
		if v <= int64(s) {
			b = append(b, int(v))
		}
	}
	if len(b) < k {
		return 0
	}
	sort.Ints(b)
	sum := 0
	for i := 0; i < k; i++ {
		sum += b[i]
		if sum > s {
			return 0
		}
	}
	return sum
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

package main

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

func solve() {
	n := readInt()
	s := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	lo := 0
	hi := n
	ans := 0
	T := 0
	for lo <= hi {
		k := (lo + hi) / 2
		t := isOk(k, a, s)
		if t > 0 {
			lo = k + 1
			ans = k
			T = t
		} else {
			hi = k - 1
		}
	}
	fmt.Println(ans, T)
}

func isOk(k int, a []int, s int) int {
	b := make([]int, 0)
	for i := 0; i < len(a); i++ {
		v := int64(a[i]) + int64(k)*int64(i+1)
		if v <= int64(s) {
			b = append(b, int(v))
		}
	}
	if len(b) < k {
		return 0
	}
	sort.Ints(b)
	sum := 0
	for i := 0; i < k; i++ {
		sum += b[i]
	}
	return sum
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

package main

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

func solve() {
	n := readInt()
	s := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	lo := 0
	hi := n
	ans := 0
	T := 0
	for lo <= hi {
		k := (lo + hi) / 2
		t := isOk(k, a, s)
		if t > 0 {
			lo = k + 1
			if ans < k {
				ans = k
				T = t
			}
		} else {
			hi = k - 1
		}
	}
	fmt.Println(ans, T)
}

func isOk(k int, a []int, s int) int {
	b := make([]int, 0)
	maxSum := int64(s)
	maxK := int64(k)
	for i := 0; i < len(a); i++ {
		v := int64(a[i]) + maxK*int64(i+1)
		if v <= maxSum {
			b = append(b, int(v))
		}
	}
	if len(b) < k {
		return 0
	}
	sort.Ints(b)
	sum := 0
	for i := 0; i < k; i++ {
		sum += b[i]
		if sum > s {
			return 0
		}
	}
	return sum
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

package main

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

func Init() {
}

func Solve(io *FastIO) {
    N := io.NextInt()
    S := io.NextLong()
    A := io.NextIntArrayOffset(N, 1)

    sort.Ints(A[1 : N + 1])

    baseSum := int64(0)
    prevCost := int64(0)
    for i := 1; i <= N; i++ {
        baseSum += int64(A[i])
        additional := (int64(i) * int64(i) * int64(i + 1)) >> 1
        nextCost := baseSum + additional
        if nextCost > S {
            io.Println(i - 1, prevCost)
            return
        }
        prevCost = nextCost
    }
    io.Println(N, prevCost)
}

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


There is a special offer in Vasya's favourite supermarket: if the customer buys $$$a$$$ chocolate bars, he or she may take $$$b$$$ additional bars for free. This special offer can be used any number of times.Vasya currently has $$$s$$$ roubles, and he wants to get as many chocolate bars for free. Each chocolate bar costs $$$c$$$ roubles. Help Vasya to calculate the maximum possible number of chocolate bars he can get!

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of testcases. Each of the next $$$t$$$ lines contains four integers $$$s, a, b, c~(1 \le s, a, b, c \le 10^9)$$$ — the number of roubles Vasya has, the number of chocolate bars you have to buy to use the special offer, the number of bars you get for free, and the cost of one bar, respectively.

Print $$$t$$$ lines. $$$i$$$-th line should contain the maximum possible number of chocolate bars Vasya can get in $$$i$$$-th test.

NoteIn the first test of the example Vasya can buy $$$9$$$ bars, get $$$3$$$ for free, buy another bar, and so he will get $$$13$$$ bars.In the second test Vasya buys $$$1000000000$$$ bars and gets $$$1000000000000000000$$$ for free. So he has $$$1000000001000000000$$$ bars.

package main

import (
    "fmt"
)

func main() {
    var count int
    fmt.Scanf("%d\n", &count)
    for i := 0; i < count; i++ {
        var m, c1, c2, price, res int64
        fmt.Scanf("%d %d %d %d\n", &m, &c1, &c2, &price)
        res = m / price
        res += (res / c1) * c2
        fmt.Println(res)
    }
}

package main

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

func ReadNumber(in *bufio.Reader) int64 {
	line, _ := in.ReadString('\n')
	num, _ := strconv.ParseInt(strings.TrimSpace(line[:len(line)-1]), 10, 64)
	return num
}

func ReadArray(in *bufio.Reader) []int64 {
	line, _ := in.ReadString('\n')

	strs := strings.Split(strings.TrimSpace(line[:len(line)-1]), " ")
	nums := make([]int64, len(strs))
	for i, str := range strs {
		nums[i], _ = strconv.ParseInt(str, 10, 64)
	}
	return nums
}

func main() {
	in := bufio.NewReader(os.Stdin)
	t := int(ReadNumber(in))
	for i := 0; i < t; i++ {
		nums := ReadArray(in)
		a := nums[0] / nums[3]
		b := a / nums[1]
		c := b * nums[2]
		fmt.Println(a + c)
	}
}

package main

import (
    "fmt"
    "os"
    )

func main() {

    var n,s,l,d int64
    var i,T int16
    var ans int64

    fmt.Scanf("%d\n", &T)

    for i=0; i< T; i++ {
        fmt.Scanf("%d%d%d%d\n", &n, &s, &l, &d)
        ans = n/d
        ans = ans + ((ans/s)*l)
        fmt.Println(ans)
    }
    os.Exit(0)
}

package main

import "fmt"

func main() {
	var t, s, a, b, c int64
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&s, &a, &b, &c)
		fmt.Println(s/c + (s / c / a * b))
	}
}

package main

import "fmt"

func main() {

	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		var s, a, b, c int64
		fmt.Scan(&s, &a, &b, &c)

		var total int64
		total = (s / c)
		total = total + (total/a)*b

		fmt.Println(total)
	}
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	for i := 0; i < N; i++ {
		s, a, b, c := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()
		k := int64(s / c)
		fmt.Println(k + int64(int64(int64(k)/int64(a))*int64(b)))
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	//writer.WriteString(fmt.Sprintf("%s", Problem705A()))
	Problem1065A()
}

func Problem1065A() {
	t := getI()
	ans := make([]int64,t)
	for i := 0; i < t; i++ {
		money := getI64()
		limitForBonus := getI64()
		bonusChoco := getI64()
		priceChoco := getI64()

		primaryBuy := money / priceChoco
		optBonus := primaryBuy / limitForBonus
		totalBonus := optBonus * bonusChoco

		ans[i] = primaryBuy + totalBonus
	}
	for dig := range ans {
		fmt.Println(ans[dig])
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, s, a, b, c int64
	fmt.Scan(&t)
	for i := int64(0); i < t; i++ {
		fmt.Scan(&s, &a, &b, &c)
		pac := s / (a * c)
		left := s % (a * c)
		fmt.Println(pac*(a+b) + left/c)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	var r []string
	for i:=0;i<t;i++ {
		var s,a,b,c int64
		fmt.Scan(&s,&a,&b,&c)
		s /=c
		r = append(r,fmt.Sprint((s/a)*(a+b)+(s%a)))
	}
	for _,l := range(r) {
		fmt.Println(l)
	}
}

package main

import "fmt"

func main() {
	var t, s, a, b, c int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&s, &a, &b, &c)
		fmt.Println(s/c + (s / c / a * b))
	}
}

package main

import "fmt"

func main() {

	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		var s, a, b, c int
		fmt.Scan(&s, &a, &b, &c)

		total := (s / c)
		total = total + (total/a)*b

		fmt.Println(total)
	}
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	for i := 0; i < N; i++ {
		s, a, b, c := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()
		k := s / c
		fmt.Println(k + (k/a)*b)
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	//writer.WriteString(fmt.Sprintf("%s", Problem705A()))
	Problem1065A()
}

func Problem1065A() {
	t := getI()
	for i := 0; i < t; i++ {
		s := getI()
		a := getI()
		b := getI()
		c := getI()

		bonus := s/a * b
		buy := (s/a * c)
		left := (s - buy) * c

		fmt.Println((buy + left + bonus))
	}
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	//writer.WriteString(fmt.Sprintf("%s", Problem705A()))
	Problem1065A()
}

func Problem1065A() {
	t := getI()
	ans := make([]int64,t)
	for i := 0; i < t; i++ {
		s := getI64()
		a := getI64()
		b := getI64()
		c := getI64()

		bonus := s/a * b
		buy := (s/a * c)
		left := (s - buy) * c

		ans[i] = buy + left + bonus
	}
	for dig := range ans {
		fmt.Println(ans[dig])
	}
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	//writer.WriteString(fmt.Sprintf("%s", Problem705A()))
	Problem1065A()
}

func Problem1065A() {
	t := getI()
	ans := make([]int64,t)
	for i := 0; i < t; i++ {
		money := getI64()
		limitForBonus := getI64()
		bonusChoco := getI64()
		priceChoco := getI64()

		primaryBuy := money / priceChoco
		optBonus := primaryBuy / limitForBonus
		totalBonus := optBonus * bonusChoco

		fmt.Println("primaryBuy totalBonus ", primaryBuy, totalBonus)
		ans[i] = primaryBuy + totalBonus
	}
	for dig := range ans {
		fmt.Println(ans[dig])
	}
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	//writer.WriteString(fmt.Sprintf("%s", Problem705A()))
	Problem1065A()
}

func Problem1065A() {
	t := getI()
	ans := make([]int,t)
	for i := 0; i < t; i++ {
		s := getI()
		a := getI()
		b := getI()
		c := getI()

		bonus := s/a * b
		buy := (s/a * c)
		left := (s - buy) * c

		ans[i] = buy + left + bonus
	}
	for dig := range ans {
		fmt.Println(ans[dig])
	}
}


Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest way to get to the olympiad.Vladik knows n airports. All the airports are located on a straight line. Each airport has unique id from 1 to n, Vladik's house is situated next to the airport with id a, and the place of the olympiad is situated next to the airport with id b. It is possible that Vladik's house and the place of the olympiad are located near the same airport. To get to the olympiad, Vladik can fly between any pair of airports any number of times, but he has to start his route at the airport a and finish it at the airport b.Each airport belongs to one of two companies. The cost of flight from the airport i to the airport j is zero if both airports belong to the same company, and |i - j| if they belong to different companies.Print the minimum cost Vladik has to pay to get to the olympiad.

The first line contains three integers n, a, and b (1 ≤ n ≤ 105, 1 ≤ a, b ≤ n) — the number of airports, the id of the airport from which Vladik starts his route and the id of the airport which he has to reach.  The second line contains a string with length n, which consists only of characters 0 and 1. If the i-th character in this string is 0, then i-th airport belongs to first company, otherwise it belongs to the second.

Print single integer — the minimum cost Vladik has to pay to get to the olympiad.

NoteIn the first example Vladik can fly to the airport 2 at first and pay |1 - 2| = 1 (because the airports belong to different companies), and then fly from the airport 2 to the airport 4 for free (because the airports belong to the same company). So the cost of the whole flight is equal to 1. It's impossible to get to the olympiad for free, so the answer is equal to 1. In the second example Vladik can fly directly from the airport 5 to the airport 2, because they belong to the same company.

package main

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

func main() {
	n, a, b := read3i()
	str := readline()
	if len(str) < n {
		str = readline()
	}
	a--
	b--
	if str[a] == str[b] {
		fmt.Fprintln(writer, 0)
	} else {
		fmt.Fprintln(writer, 1)
	}
	writer.Flush()
}

func getPrimes(n int) []int {
	isPrime := make([]bool, n)
	for i := 2; i < len(isPrime); i++ {
		isPrime[i] = true
	}
	root := int(math.Sqrt(float64(n)))
	for i := 2; i <= root; i++ {
		if isPrime[i] {
			for j := i * i; j < n; j += i {
				isPrime[j] = false
			}
		}
	}
	primes := make([]int, 0)
	for i, v := range isPrime {
		if v {
			primes = append(primes, i)
		}
	}
	return primes
}

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

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

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

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

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

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

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

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func read3i() (int, int, int) {
	return readi(), readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}

package main

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

func solve() {
    _, a, b := readInt(), readInt()-1, readInt()-1
    s := readString()
    ans := 0
    if s[a] != s[b] {
		ans = 1
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"fmt"
)

func main() {
	var n, a, b int64
	var s string
	fmt.Scan(&n, &a, &b, &s)

	r := 1
	if s[a-1] == s[b-1]{
		r = 0
	}

	fmt.Println(r)
}

package main

import(
"fmt"
)

func main() {
    var n,a,b int
    fmt.Scanf("%d %d %d",&n,&a,&b)
    var s string
    fmt.Scan(&s)
    eq := s[a-1] == s[b-1]
    if eq {
        fmt.Println(0)
    } else {
        fmt.Println(1)
    }
}

package main

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

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

	re := regexp.MustCompile(`\r?\n`)

	reader := bufio.NewReader(os.Stdin)
	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s = re.ReplaceAllString(s, "")
		if a == b || s[a-1] == s[b-1] {
			fmt.Println(0)
		} else {
			fmt.Println(1)
		}
	}
}

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

func pcheck(i bool) {
	if i {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	var n, a, b int
	scanf("%d %d %d\n", &n, &a, &b)
	s := getLine()
	if s[a-1] == s[b-1] {
		printf("0\n")
	} else {
		printf("1\n")
	}
}

package main

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

func main() {
	sc := NewScanner()
	_, a, b := sc.NextInt(), sc.NextInt(), sc.NextInt()

	S := sc.NextLine()

	a--
	b--

	if S[a] == S[b] {
		fmt.Println(0)
		return
	}

	fmt.Println(1)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main
import (
    "fmt"
)

func main(){
    var n, start, finish int
    var airports string
    fmt.Scan(&n, &start, &finish, &airports)
    if airports[start - 1] == airports[finish - 1] {
        fmt.Println(0)
    } else {
        fmt.Println(1)
    }
}

package main

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

func solve() {
    _, a, b := readInt(), readInt()-1, readInt()-1
    s := readString()
    ans := 0
    if s[a] != s[b] {
        cur := abs(a-b)
        for i := range s {
            if s[i] != s[b] {
                cur = min(cur, abs(i-b))
            } else {
                cur = min(cur, abs(i-a))
            }
        }
        ans = min(cur, 2)
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

func solve() {
    _, a, b := readInt(), readInt()-1, readInt()-1
    s := readString()
    ans := 0
    if s[a] != s[b] {
        cur := abs(a-b)
        for i := range s {
            if s[i] != s[b] {
                cur = min(cur, abs(i-b))
            }
        }
        ans = cur
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
    "fmt"
    "math"
)

func abs(a , b int) int {
    return int(math.Abs(float64(a-b)))
}

func main() {
    var n,a,b int
    fmt.Scanf("%d %d %d",&n,&a,&b)
    var s string
    fmt.Scan(&s)
    //company 1
    dA , dB := 1000000, 10000000
    for i:= 1; i <= n; i++ {
        if s[i-1] == '1' {
            if abs(i,a) < dA {
                dA = abs(i,a)
            }
            if abs(i,b) < dB {
                dB = abs(i,b)
            }
        }
    }
    dis := dA + dB
    dA , dB = 1000000, 10000000
    for i:= 1; i <= n; i++ {
        if s[i-1] == '0' {
            if abs(i,a) < dA {
                dA = abs(i,a)
            }
            if abs(i,b) < dB {
                dB = abs(i,b)
            }
        }
    }
    if dA + dB < dis {
        dis = dA + dB
    }
    fmt.Println(dis)
}

package main

import(
"fmt"
)

func main() {
    var n,a,b int
    fmt.Scanf("%d %d %d",&n,&a,&b)
    var s string
    fmt.Scan(&s)
    allEq := true
    for i:=1; i < n; i++ {
       if s[i] != s[i-1] {
            allEq = false
            break
        }
    }
    if allEq {
        fmt.Println(0)
    } else {
        fmt.Println(1)
    }
}


Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string s, consisting of characters "x" and "y", and uses two following operations at runtime:  Find two consecutive characters in the string, such that the first of them equals "y", and the second one equals "x" and swap them. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string.  Find in the string two consecutive characters, such that the first of them equals "x" and the second one equals "y". Remove these characters from the string. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string. The input for the new algorithm is string s, and the algorithm works as follows:  If you can apply at least one of the described operations to the string, go to step 2 of the algorithm. Otherwise, stop executing the algorithm and print the current string.  If you can apply operation 1, then apply it. Otherwise, apply operation 2. After you apply the operation, go to step 1 of the algorithm. Now Vitaly wonders, what is going to be printed as the result of the algorithm's work, if the input receives string s.

The first line contains a non-empty string s.  It is guaranteed that the string only consists of characters "x" and "y". It is guaranteed that the string consists of at most 106 characters. It is guaranteed that as the result of the algorithm's execution won't be an empty string.

In the only line print the string that is printed as the result of the algorithm's work, if the input of the algorithm input receives string s.

NoteIn the first test the algorithm will end after the first step of the algorithm, as it is impossible to apply any operation. Thus, the string won't change.In the second test the transformation will be like this:  string "yxyxy" transforms into string "xyyxy";  string "xyyxy" transforms into string "xyxyy";  string "xyxyy" transforms into string "xxyyy";  string "xxyyy" transforms into string "xyy";  string "xyy" transforms into string "y". As a result, we've got string "y". In the third test case only one transformation will take place: string "xxxxxy" transforms into string "xxxx". Thus, the answer will be string "xxxx".

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
)

func main() {
	var s string
	fmt.Fscan(reader, &s)
	x := strings.Count(s, "x")
	y := len(s) - x
	if x > y {
		fmt.Print(strings.Repeat("x", x-y))
	} else {
		fmt.Print(strings.Repeat("y", y-x))
	}
}

package main

import "os"
import "bufio"
import "fmt"

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

func main(){
	var s string
	r := bufio.NewReader(os.Stdin)
	fmt.Fscan(r, &s)
	w := bufio.NewWriter(os.Stdout)
	cx, cy := 0, 0
	for i:=0; i<len(s); i++ {
		if string(s[i]) != "y" {
			cx += 1
		} else {
			cy += 1
		}
	}
	m := min(cx, cy)
	cx -= m
	cy -= m
	if cx == 0 {
		for j:=0; j<cy; j++ {
			w.WriteString("y")
		}
	} else {
		for k:=0; k<cx; k++ {
			w.WriteString("x")
		}
	}
	w.Flush()
	w.WriteString("\n")
	w.Flush()
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    var s string
    fmt.Fscan(reader,&s)
    x, y := 0, 0
    for _, v := range s {
        if v == 'x' { x++ } else { y++ }
    }
    if x > y {
        n := x-y
        for i := 0; i < n; i++ { writer.WriteRune('x') }
    } else {
        n := y-x
        for i := 0; i < n; i++ { writer.WriteRune('y') }
    }
    writer.WriteRune('\n')
    writer.Flush()
}

// 255B
package main

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

func main() {
	var a string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &a)
	x := strings.Count(a, "x")
	y := len(a) - x
	if x > y {
		fmt.Print(strings.Repeat("x", x-y))
	} else {
		fmt.Print(strings.Repeat("y", y-x))
	}
}

// 255B-mic_rizal
package main

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

func main() {
    var str string
    var x, y int
    o := bufio.NewWriter(os.Stdout)
    z := bufio.NewReader(os.Stdin)
    fmt.Fscan(z, &str)
    for i := 0; i < len(str); i++ {
        if str[i] == 'x' {
            x++
        }
        if str[i] == 'y' {
            y++
        }
    }
    if x > y {
        for i := 0; i < (x - y); i++ {
            o.WriteString(string('x'))
            //fmt.Print("x")
        }
    } else {
        for i := 0; i < (y - x); i++ {
            o.WriteString(string('y'))
            //fmt.Print("y")
        }
    }
    o.Flush()
    fmt.Println()
}

package main

import "os"
import "bufio"

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

func main(){
	var s string
	r := bufio.NewScanner(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	s = r.Text()
	cx, cy := 0, 0
	for i:=0; i<len(s); i++ {
		if string(s[i]) != "y" {
			cx += 1
		} else {
			cy += 1
		}
	}
	m := min(cx, cy)
	cx -= m
	cy -= m
	if cx == 0 {
		for j:=0; j<cy; j++ {
			w.WriteString("y")
			w.Flush()
		}
	} else {
		for k:=0; k<cx; k++ {
			w.WriteString("x")
			w.Flush()
		}
	}
	w.WriteString("\n")
	w.Flush()
}

// 255B
package main

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

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	n := x - y
	if n > 0 {
		for ; n >= 0; n-- {
			fmt.Fprint(out, "x")
		}
	} else {
		for ; n <= 0; n++ {
			fmt.Fprint(out, "y")
		}
	}

	out.Flush()
}

// 255B
package main

import (
	"bufio"
	"os"
)

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	n := x - y
	if n > 0 {
		for ; n > 0; n-- {
			out.WriteString("x")
		}
	} else {
		for ; n < 0; n++ {
			out.WriteString("y")
		}
	}
	out.Flush()
	out.Flush()
}

// 255B
package main

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

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewScanner(os.Stdin)
	in.Scan()
	a = in.Text()
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	if x > y {
		fmt.Print("x")
	} else {
		fmt.Print("y")
	}
}

// 255B
package main

import (
	"bufio"
	"os"
)

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	n := x - y
	if n > 0 {
		for ; n > 0; n-- {
			out.WriteRune('x')
		}
	} else {
		for ; n < 0; n++ {
			out.WriteRune('y')
		}
	}
	out.WriteRune('\n')
	out.Flush()
}

// 255B
package main

import (
	"bufio"
	"os"
)

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	n := x - y
	if n > 0 {
		for ; n > 0; n-- {
			out.WriteString("x")
		}
	} else {
		for ; n < 0; n++ {
			out.WriteString("y")
		}
	}
}

// 255B
package main

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

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	n := x - y
	if n > 0 {
		for ; n > 0; n-- {
			fmt.Fprint(out, "x")
		}
	} else {
		for ; n < 0; n++ {
			fmt.Fprint(out, "y")
		}
	}

	out.Flush()
}

// 255B
package main

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

func main() {
	var a string
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	x := strings.Count(a, "x")
	y := len(a) - x
	if x > y {
		fmt.Fprint(out, strings.Repeat("x", x-y))
	} else {
		fmt.Fprint(out, strings.Repeat("y", y-x))
	}
	out.WriteRune('\n')
	out.Flush()
}

// 255B
package main

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

func main() {
	var a string
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	x := strings.Count(a, "x")
	y := len(a) - x
	if x > y {
		fmt.Fprint(out, strings.Repeat("x", x-y))
	} else {
		fmt.Fprint(out, strings.Repeat("y", y-x))
	}
	out.Flush()
}

// 255B
package main

import (
	"bufio"
	"os"
)

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Scan()
	a = in.Text()
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	n := x - y
	if n > 0 {
		for ; n > 0; n-- {
			out.WriteString("x")
		}
	} else {
		for ; n < 0; n++ {
			out.WriteString("y")
		}
	}
	out.Flush()
}

// 255B
package main

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

func main() {
	var a string
	x, y := 0, 0
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &a)
	for i := 0; i < len(a); i++ {
		if a[i] == 'x' {
			x++
		} else {
			y++
		}
	}
	n := x - y
	if n > 0 {
		for ; n > 0; n-- {
			out.WriteRune('x')
		}
	} else {
		for ; n < 0; n++ {
			out.WriteRune('y')
		}
	}
}