Timur's grandfather gifted him a chessboard to practice his chess skills. This chessboard is a grid $$$a$$$ with $$$n$$$ rows and $$$m$$$ columns with each cell having a non-negative integer written on it. Timur's challenge is to place a bishop on the board such that the sum of all cells attacked by the bishop is maximal. The bishop attacks in all directions diagonally, and there is no limit to the distance which the bishop can attack. Note that the cell on which the bishop is placed is also considered attacked. Help him find the maximal sum he can get.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains the integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 200$$$, $$$1 \leq m \leq 200$$$). The following $$$n$$$ lines contain $$$m$$$ integers each, the $$$j$$$-th element of the $$$i$$$-th line $$$a_{ij}$$$ is the number written in the $$$j$$$-th cell of the $$$i$$$-th row $$$(0\leq a_{ij} \leq 10^6)$$$ It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$4\cdot10^4$$$.

For each test case output a single integer, the maximum sum over all possible placements of the bishop.

NoteFor the first test case here the best sum is achieved by the bishop being in this position:

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, m int
		fmt.Fscan(reader, &n, &m)
		a := make([][]int, n)
		for i := 0; i < n; i++ {
			a[i] = make([]int, m)
		}
		d1 := make(map[int]int)
		d2 := make(map[int]int)
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Fscan(reader, &a[i][j])
				d1[i+j] += a[i][j]
				d2[i-j] += a[i][j]
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				tmp := d1[i+j] + d2[i-j] - a[i][j]
				if tmp > ans {
					ans = tmp
				}
			}
		}
		// fmt.Println(ans)
		write_int(f, ans)
		write_string(f, "\n")
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, m int
		fmt.Fscan(reader, &n, &m)
		a := make([][]int, n)
		for i := 0; i < n; i++ {
			a[i] = make([]int, m)
		}
		d1 := make(map[int]int)
		d2 := make(map[int]int)
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Fscan(reader, &a[i][j])
				d1[i+j] += a[i][j]
				d2[i-j] += a[i][j]
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				tmp := d1[i+j] + d2[i-j] - a[i][j]
				if tmp > ans {
					ans = tmp
				}
			}
		}
		fmt.Println(ans)

	}
}

package main

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

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

	n := readInt(in)
	for i := 0; i < n; i++ {
		solution(in, out)
	}
}

func solution(in *bufio.Reader, out *bufio.Writer) {
	arr := readArrInt(in)
	n := arr[0]
	m := arr[1]

	board := make([][]int, n)
	for i := 0; i < n; i++ {
		board[i] = readArrInt(in)
	}

	maxSum := 0
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			// get the sum by moving up (+1, +1) from current location
			sum := 0
			for k := 1; i+k < n && j+k < m; k++ {
				sum += board[i+k][j+k]
			}

			for k := -1; i+k >= 0 && j+k >= 0; k-- {
				sum += board[i+k][j+k]
			}

			for k := 1; i+k < n && j-k >= 0; k++ {
				sum += board[i+k][j-k]
			}

			for k := 1; i-k >= 0 && j+k < m; k++ {
				sum += board[i-k][j+k]
			}

			sum += board[i][j]
			maxSum = Max(maxSum, sum)
		}
	}

	out.WriteString(strconv.Itoa(maxSum) + "\n")
}

func Max(sum int, sum2 int) int {
	if sum > sum2 {
		return sum
	}
	return sum2

}

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

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 readLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	return line
}

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 (
	"bufio"
	"fmt"
	"io"
	"os"
)

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

func solve(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n, m int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &m)
		a := make([][]int, n)
		// Top left to bottom right diags
		d1 := make([][]int, n)
		// Bottom left to top right diags
		d2 := make([][]int, n)
		for i := 0; i < n; i++ {
			a[i] = make([]int, m)
			d1[i] = make([]int, m)
			d2[i] = make([]int, m)
		}
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Fscan(in, &a[i][j])
				d1[i][j] = a[i][j]
				d2[i][j] = a[i][j]
				if i > 0 && j > 0 {
					d1[i][j] += d1[i-1][j-1]
				}
				if i > 0 && j < m-1 {
					d2[i][j] += d2[i-1][j+1]
				}
			}
		}
		for i := n - 1; i > 0; i-- {
			for j := 0; j < m; j++ {
				if j > 0 {
					d1[i-1][j-1] = d1[i][j]
				}
				if j < m-1 {
					d2[i-1][j+1] = d2[i][j]
				}
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				ck := d1[i][j] + d2[i][j] - a[i][j]
				if ck > ans {
					ans = ck
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

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

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

func main(){
  defer writer.Flush()

  var T int
  fmt.Fscan(reader,&T)

  for test := 1; test <= T; test++ {
    var n,m int
    fmt.Fscan(reader,&n,&m)

    var a [][]int
    a = make([][]int,n + 1)
    for i := 1; i <= n; i++ {
      a[i] = make([]int,m + 1)
      for j := 1; j <= m; j++ {
        fmt.Fscan(reader,&a[i][j])
      }
    }

    calc := func (tx,ty,i,j int) int {
      ret := 0
      for ; i + tx >= 1 && j + ty >= 1 && i + tx <= n && j + ty <= m; {
        i += tx
        j += ty
        ret += a[i][j]
      }
      return ret
    }

    ans := 0
    for i := 1; i <= n; i++ {
      for j := 1; j <= m; j++ {
        sum := calc(-1,-1,i,j) + calc(-1,1,i,j) + calc(1,-1,i,j) + calc(1,1,i,j) + a[i][j]
        if ans < sum {
          ans = sum
        }
      }
    }
    fmt.Fprintf(writer,"%d\n",ans)
  }
}

package main

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

func Sol(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	for fmt.Fscan(in, &T); T > 0; T-- {
		var n, m int
		fmt.Fscan(in, &n, &m)
		a := make([][]int, n)
		for i := 0;i < n; i++ {
			a[i] = make([]int, m)
			for j := 0;j < m; j++ {
				fmt.Fscan(in, &a[i][j])
			}
		}
		max := func(a, b int) int {
			if a > b {
				return a
			}
			return b
		}
		var ans int
		for i := 0;i < n; i++ {
			for j := 0;j < m; j++ {
				temp := 0
				p, q := i, j
				for {
					if p < 0 || p >= n || q < 0 || q >= m {
						break
					}
					temp += a[p][q]
					p++
					q++
				}
				p, q = i, j
				for {
					if p < 0 || p >= n || q < 0 || q >= m {
						break
					}
					temp += a[p][q]
					p++
					q--
				}
				p, q = i, j
				for {
					if p < 0 || p >= n || q < 0 || q >= m {
						break
					}
					temp += a[p][q]
					p--
					q++
				}
				p, q = i, j
				for {
					if p < 0 || p >= n || q < 0 || q >= m {
						break
					}
					temp += a[p][q]
					p--
					q--
				}
				temp -= a[i][j] * 3
				ans = max(ans, temp)
			}
		}
		fmt.Fprintln(out, ans)
	}
}

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

package main

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

func toInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func sumDiag(grid [][]int, i, j int) int {
	total := grid[i][j]
	a, b := i+1, j+1
	for a < len(grid) && b < len(grid[a]) {
		total += grid[a][b]
		a++
		b++
	}
	a, b = i-1, j-1

	for a >= 0 && b >= 0 {
		total += grid[a][b]
		a--
		b--
	}

	a, b = i-1, j+1
	for a >= 0 && b < len(grid[a]) {
		total += grid[a][b]
		a--
		b++
	}
	a, b = i+1, j-1
	for a < len(grid) && b >= 0 {
		total += grid[a][b]
		a++
		b--
	}
	return total
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	testCases, _ := strconv.Atoi(scanner.Text())

	for idx := 0; idx < testCases; idx++ {
		scanner.Scan()
		mn := strings.Split(scanner.Text(), " ")
		m, n := toInt(mn[0]), toInt(mn[1])

		grid := make([][]int, 0)

		for i := 0; i < m; i++ {
			scanner.Scan()
			line := strings.Split(scanner.Text(), " ")
			lineInt := make([]int, 0)
			for idx := 0; idx < len(line); idx++ {
				lineInt = append(lineInt, toInt(line[idx]))
			}
			grid = append(grid, lineInt)
		}
		maximum := math.MinInt
		for i := 0; i < m; i++ {
			for j := 0; j < n; j++ {
				t := sumDiag(grid, i, j)
				if t > maximum {
					maximum = t
				}
			}
		}

		fmt.Println(maximum)

	}
}

package main

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

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func maxFloat(a float64, nums ...float64) float64 {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func fprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

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

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var x, y int
		fmt.Fscan(in, &x, &y)
		arr := make([][]int, x)
		cnt1, cnt2 := make([][]int, x), make([][]int, x)
		for i := 0; i < x; i++ {
			arr[i] = make([]int, y)
			cnt1[i] = make([]int, y)
			cnt2[i] = make([]int, y)
		}
		for i := 0; i < x; i++ {
			for j := 0; j < y; j++ {
				fmt.Fscan(in, &arr[i][j])
				cnt1[i][j] = arr[i][j]
				cnt2[i][j] = arr[i][j]
			}
		}

		for i := 0; i < x-1; i++ {
			for j := 0; j < y-1; j++ {
				cnt1[i+1][j+1] += cnt1[i][j]
			}
		}
		for i := 0; i < x-1; i++ {
			for j := 1; j < y; j++ {
				cnt2[i+1][j-1] += cnt2[i][j]
			}
		}
		//fmt.Println(cnt1)
		//fmt.Println(cnt2)

		ans := 0
		for i := 0; i < x; i++ {
			for j := 0; j < y; j++ {
				cur := -arr[i][j]

				curX, curY := i, j
				for curX < x-1 && curY > 0 {
					curX++
					curY--
				}
				cur += cnt2[curX][curY]
				//fmt.Print(cur, " ")

				curX, curY = i, j
				for curX < x-1 && curY < y-1 {
					curX++
					curY++
				}
				//fmt.Println(curX, curY)
				cur += cnt1[curX][curY]
				//fmt.Println(cur)
				ans = max(ans, cur)
			}
		}
		fmt.Fprintln(out, ans)
	}
}

/*maxEvenCnt1, maxOddCnt1 := 0, 0
for i := 0; i < y; i++ {
	cur := cnt1[x-1][i]
	if i%2 == 0 {
		maxEvenCnt1 = max(maxEvenCnt1, cur)
	} else {
		maxOddCnt1 = max(maxOddCnt1, cur)
	}
}
for i := 0; i < x; i++ {
	cur := cnt1[i][y-1]
	if i%2 == 0 {
		maxEvenCnt1 = max(maxEvenCnt1, cur)
	} else {
		maxOddCnt1 = max(maxOddCnt1, cur)
	}
}

for i := 0; i < x-1; i++ {
	for j := 1; j < y; j++ {
		cnt2[i+1][j-1] += cnt2[i][j]
	}
}
maxEvenCnt2, maxOddCnt2 := 0, 0
for i := 0; i < y; i++ {
	cur := cnt2[x-1][i]
	if i%2 == 0 {
		maxEvenCnt2 = max(maxEvenCnt2, cur)
	} else {
		maxOddCnt2 = max(maxOddCnt2, cur)
	}
}
for i := 0; i < x; i++ {
	cur := cnt2[i][y-1]
	if i%2 == 0 {
		maxEvenCnt2 = max(maxEvenCnt2, cur)
	} else {
		maxOddCnt2 = max(maxOddCnt2, cur)
	}
}*/

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)
func slove() {
	var n, m int
	fmt.Fscan(r, &n, &m)
	board, one, two := make([][]int, n), make([][]int, n+1), make([][]int, n+1)
	for i := range board {
		board[i], one[i], two[i] = make([]int, m), make([]int, m+1), make([]int, m+1)
	}
	one[n], two[n] = make([]int, m+1), make([]int, m+1)
	for i := range board {
		for j := range board[i] {
			fmt.Fscan(r, &board[i][j])
			one[i+1][j+1] = one[i][j] + board[i][j]
			two[i+1][j] = two[i][j+1] + board[i][j]
		}
	}
	for i:=n-1;i>=0;i-- {
		for j  := range board[i] {
			one[i][j] = one[i+1][j+1]
			two[i][j+1] = two[i+1][j]
		}
	}
	ans := 0
	for i := range board {
		for j := range board[i] {
			ans = max(ans, one[i+1][j+1] + two[i+1][j] - board[i][j])
		}
	}
	fmt.Fprintln(w, ans)
}

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

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

func D(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	t := 0
	fmt.Fscan(in, &t)
	for k := 0; k < t; k++ {
		n, m := 0, 0
		fmt.Fscan(in, &n, &m)
		matrix := make([][]int, n)
		for i := range matrix {
			matrix[i] = make([]int, m)
		}
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				fmt.Fscan(in, &matrix[i][j])
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				ans = max(ans, dfs(matrix, []int{i, j}, n, m))
			}
		}
		fmt.Fprintln(out, ans)
	}
}

var posx = [4]int{-1, 1, 1, -1}
var posy = [4]int{-1, 1, -1, 1}

func dfs(matrix [][]int, start []int, n int, m int) int {
	res := 0
	x, y := start[0], start[1]
	for i := 0; i < 4; i++ {
		x1 := x
		y1 := y
		for {
			x1 += posx[i]
			y1 += posy[i]
			if x1 < 0 || y1 < 0 || x1 >= n || y1 >= m {
				break
			} else {
				res += matrix[x1][y1]
			}
		}
	}
	return res + matrix[x][y]
}

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

package main

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

func getMySum(x [][]int, n int, m int, a int, b int) int {
	sum := 0

	tmpa := a
	tmpb := b
	for tmpa >= 0 && tmpb >= 0 && tmpa <= n-1 && tmpb <= m-1 {
		sum += x[tmpa][tmpb]
		tmpa--
		tmpb--
	}

	tmpa = a
	tmpb = b
	tmpa++
	tmpb++
	for tmpa >= 0 && tmpb >= 0 && tmpa <= n-1 && tmpb <= m-1 {
		sum += x[tmpa][tmpb]
		tmpa++
		tmpb++
	}

	tmpa = a
	tmpb = b
	tmpa--
	tmpb++
	for tmpa >= 0 && tmpb >= 0 && tmpa <= n-1 && tmpb <= m-1 {
		sum += x[tmpa][tmpb]
		tmpa--
		tmpb++
	}

	tmpa = a
	tmpb = b
	tmpa++
	tmpb--
	for tmpa >= 0 && tmpb >= 0 && tmpa <= n-1 && tmpb <= m-1 {
		sum += x[tmpa][tmpb]
		tmpa++
		tmpb--
	}

	return sum
}

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		text, _ := reader.ReadString('\n')
		ninps := strings.Fields(text)
		n, _ := strconv.Atoi(ninps[0])
		m, _ := strconv.Atoi(ninps[1])

		mat := make([][]int, n)
		//maxarr := make([][]int, n)

		for i := 0; i < n; i++ {
			mat[i] = make([]int, m)
			//maxarr[i] = make([]int, m)

			text, _ = reader.ReadString('\n')
			ninps = strings.Fields(text)
			for j, val := range ninps {
				mat[i][j], _ = strconv.Atoi(val)
			}
		}

		largest := -1
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				a := getMySum(mat, n, m, i, j)
				if a > largest {
					largest = a
				}
			}
		}
		fmt.Println(largest)
	}
}

package main

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

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

func solve() string {
	var n, m int
	fmt.Fscan(in, &n, &m)
	var matrix = make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Fscan(in, &matrix[i][j])
		}
	}

	var res, tmp int

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			tmp = 0
			var x, y int
			for x, y = i, j; x < n && y < m; x, y = x+1, y+1 {
				tmp += matrix[x][y]
			}
			for x, y = i, j; x >= 0 && y < m; x, y = x-1, y+1 {
				tmp += matrix[x][y]
			}
			for x, y = i, j; x < n && y >= 0; x, y = x+1, y-1 {
				tmp += matrix[x][y]
			}
			for x, y = i, j; x >= 0 && y >= 0; x, y = x-1, y-1 {
				tmp += matrix[x][y]
			}

			tmp -= 3 * matrix[i][j]

			if tmp > res {
				res = tmp
			}
		}
	}

	return strconv.FormatInt(int64(res), 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

package main

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

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

func d1676(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var n int
	var m int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &m)
		Fscan(in, &n)

		g := make([][]int, m)
		for i := 0; i < m; i++ {
			g[i] = make([]int, n)
			for j := 0; j < n; j++ {
				Fscan(in, &x)
				g[i][j] = x
			}
		}

		l := make([]int, m+n-1)
		r := make([]int, m+n-1)

		for i := 0; i < m; i++ {
			for j := 0; j < n; j++ {
				l[i+j] += g[i][j]
				r[i-j+n-1] += g[i][j]
			}
		}

		ans := 0
		for i := 0; i < m; i++ {
			for j := 0; j < n; j++ {
				t := l[i+j] + r[i-j+n-1] - g[i][j]
				if t > ans {
					ans = t
				}
			}
		}

		Fprintln(out, ans)
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n, m int
		fmt.Fscan(in, &n, &m)

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

		sums := make([][]int64, n)
		for i := 0; i < n; i++ {
			sums[i] = make([]int64, m)
		}

		dir := [][]int{{-1, -1}, {-1, 1}, {1, -1}, {1, 1}}
		var max int64
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {

				sums[i][j] = a[i][j]
				// 4 directions
				for _, d := range dir {
					x := i + d[0]
					y := j + d[1]
					for x >= 0 && x < n && y >= 0 && y < m {
						sums[i][j] += a[x][y]
						x += d[0]
						y += d[1]
					}
				}

				if sums[i][j] > max {
					max = sums[i][j]
				}
			}
		}
		fmt.Fprintln(out, max)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(curCase int) {
		var n,m int
		Fscan(in, &n,&m)
		a := make([][]int, n)
		for i := range a {
			a[i] = make([]int, m)
			for j := range a[i] {
				Fscan(in, &a[i][j])
			}
		}
		ans :=0
		dir4 := []struct{ x, y int }{{-1, -1}, {1, 1}, {1, -1}, {-1, 1}}
		for i, r := range a {
			for j, v := range r {
				_, _ = i, j
				s := v
				for _, d := range dir4 {
					x,y := i,j
					for {
						x+=d.x
						y+=d.y
						if x < 0 || x >=n ||y<0 || y >=m {
							break
						}
						s+=a[x][y]
					}
				}
				ans = max(ans, s)
			}
		}
		Fprintln(out, ans)

	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

func main() { run(os.Stdin, os.Stdout) }
func max(a, b int) int {
	if b > a {
		return b
	}
	return a
}


Ray lost his array and needs to find it by asking Omkar. Omkar is willing to disclose that the array has the following qualities:  The array has $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) elements.  Every element in the array $$$a_i$$$ is an integer in the range $$$1 \le a_i \le 10^9.$$$  The array is sorted in nondecreasing order. Ray is allowed to send Omkar a series of queries. A query consists of two integers, $$$l$$$ and $$$r$$$ such that $$$1 \le l \le r \le n$$$. Omkar will respond with two integers, $$$x$$$ and $$$f$$$. $$$x$$$ is the mode of the subarray from index $$$l$$$ to index $$$r$$$ inclusive. The mode of an array is defined by the number that appears the most frequently. If there are multiple numbers that appear the most number of times, the smallest such number is considered to be the mode. $$$f$$$ is the amount of times that $$$x$$$ appears in the queried subarray.The array has $$$k$$$ ($$$1 \le k \le \min(25000,n)$$$) distinct elements. However, due to Ray's sins, Omkar will not tell Ray what $$$k$$$ is. Ray is allowed to send at most $$$4k$$$ queries.Help Ray find his lost array.

The only line of the input contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$), which equals to the length of the array that you are trying to find.

NoteThe first query is $$$l=1$$$ and $$$r=6$$$. The mode is $$$2$$$, and $$$2$$$ appears $$$2$$$ times, so $$$x=2$$$ and $$$f=2$$$. Note that $$$3$$$ also appears two times, but $$$2$$$ is outputted because $$$2$$$ is smaller.The second query is $$$l=1$$$ and $$$r=3$$$. The mode is $$$2$$$ and $$$2$$$ appears twice in the subarray with indices $$$[1,3]$$$.The third query is $$$l=4$$$ and $$$r=6$$$. The mode is $$$3$$$ and $$$3$$$ appears twice in the subarray with indices $$$[4,6]$$$.The fourth query is $$$l=3$$$ and $$$r=4$$$. The mode is $$$2$$$, which appears once in the subarray with indices $$$[3,4]$$$. Note that $$$3$$$ also appears once in that range, but $$$2$$$ is smaller than $$$3$$$.

package main

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

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

	n := readNum(reader)

	ask := func(l, r int) (int, int) {
		fmt.Printf("? %d %d\n", l, r)
		return readTwoNums(reader)
	}

	res := solve(n, ask)
	var buf bytes.Buffer
	buf.WriteString("!")
	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf(" %d", res[i]))
	}
	fmt.Println(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, ask func(l int, r int) (int, int)) []int {
	arr := make([]int, n)
	occ := make(map[int]int)

	var query func(l, r int) int

	query = func(l, r int) int {
		if l <= r {
			x, f := ask(l, r)

			if ff, found := occ[x]; found {
				end := r - f + ff
				for j := end - ff + 1; j <= end; j++ {
					arr[j-1] = x
				}
				delete(occ, x)
				query(l, r-f)
				return end
			}
			occ[x] = f
			var j = l
			for occ[x] > 0 {
				j = query(j, j+f-1) + 1
			}
			return query(j, r)
		}
		return l - 1
	}

	query(1, n)

	return arr
}


Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:    - 1: if this pair of cars never collided.  - 1 occurs only on the main diagonal of the matrix.  0: if no car turned over during the collision.  1: if only the i-th car turned over during the collision.  2: if only the j-th car turned over during the collision.  3: if both cars turned over during the collision. Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?

The first line contains integer n (1 ≤ n ≤ 100) — the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A.  It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.

Print the number of good cars and in the next line print their space-separated indices in the increasing order.

package main

import (
	"fmt"
)

var (
	n int
)

func main() {
	fmt.Scan(&n)
	ans := make([]int, 0, n)
	for i := 0; i < n; i++ {
		ok := true
		for j := 0; j < n; j++ {
			var v int
			fmt.Scan(&v)
			switch v {
			case 1, 3:
				ok = false
			}
		}
		if ok {
			ans = append(ans, i)
		}
	}
	fmt.Println(len(ans))
	for i, v := range ans {
		fmt.Print(v + 1)
		if i == len(ans) - 1 {
			fmt.Print("\n")
		} else {
			fmt.Print(" ")
		}
	}
}

package main

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

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

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

	n := nextInt()
	a, cnt := 0, 0
	ret := make([]int, 0, 100)

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

		for j := 0; j < n; j++ {
			a = nextInt()

			if a == 1 || a == 3 {
				ok = false
			}
		}

		if ok {
			ret = append(ret, i)
			cnt++
		}
	}

	println(cnt)

	if cnt > 0 {
		for i := range ret {
			printf("%d ", ret[i])
		}

		println()
	}
}

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

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

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

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

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

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

package main

import (
  "fmt"
)

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

  var array [100][100]int
  for i := 0; i < n; i++ {
    for j := 0; j < n; j++ {
      fmt.Scan(&array[i][j])
    }
  }
  //for i := 0; i < n; i++ {
  //  fmt.Println(array[i])
  //}

  var results [100]int
  for i := 0; i < n; i++ {
    for j := 0; j < n; j++ {
      if array[i][j] != -1 && array[i][j] != 0 && array[i][j] != 2 {

        //fmt.Println(array[i][j] != -1 && array[i][j] != 0 && array[i][j] != 2)
        //if i == 0 {
        //  fmt.Println(array[i][j])
        //}

        results[i] = 1
        //fmt.Println("results[i]: ", results[i])
      }
    }
  }

  count := 0
  for i := 0; i < n; i++ {
    if results[i] == 0 {
      count += 1
    }
  }
  fmt.Println(count)

  //fmt.Println(results)
  for i := 0; i < n; i++ {
    if results[i] == 0 {
      fmt.Println(i+1)
    }
  }
}

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

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 main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  bad := map[int]bool{}
  n := getI()
  for i := 0; i < n; i++ {
    for j := 0; j < n; j++ {
      x := getI()
      if x == -1 {
        continue
      }
      if x & 1 != 0 {
        bad[i] = true
      }
      if x & 2 != 0 {
        bad[j] = true
      }
    }
  }
  good := []int{}
  for i := 0; i < n; i++ {
    if !bad[i] {
      good = append(good, i+1)
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", len(good)))
  if len(good) != 0 {
    writer.WriteString(fmt.Sprintf("%d", good[0]))
    for i := 1; i < len(good); i++ {
      writer.WriteString(fmt.Sprintf(" %d", good[i]))
    }
    writer.WriteString("\n")
  }
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var cr int
	fmt.Fscanf(reader, "%d\n", &cr)

	mp := make(map[int]bool)
	for i := 1; i <= cr; i++ {
		for j := 1; j <= cr; j++ {
			var each int
			fmt.Fscan(reader, &each)
			switch each {
			case -1:
				continue
			case 1:
				mp[i] = true
			case 2:
				mp[j] = true
			case 3:
				mp[i], mp[j] = true, true
			}
		}
	}

	var chn []int
	for i := 1; i <= cr; i++ {
		if !mp[i] {
			chn = append(chn, i)
		}
	}

	fmt.Println(len(chn))
	for _, x := range chn {
		fmt.Print(x, " ")
	}
}

package main

import (
  "fmt"
)

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

  var array [100][100]int
  for i := 0; i < n; i++ {
    for j := 0; j < n; j++ {
      fmt.Scan(&array[i][j])
    }
  }
  //for i := 0; i < n; i++ {
  //  fmt.Println(array[i])
  //}

  var results [100]int
  for i := 0; i < n; i++ {
    for j := 0; j < n; j++ {
      if array[i][j] != -1 && array[i][j] != 0 && array[i][j] != 2 {

        //fmt.Println(array[i][j] != -1 && array[i][j] != 0 && array[i][j] != 2)
        //if i == 0 {
        //  fmt.Println(array[i][j])
        //}

        results[i] = 1
        //fmt.Println("results[i]: ", results[i])
      }
    }
  }

  count := 0
  for i := 0; i < n; i++ {
    if results[i] == 0 {
      count += 1
    }
  }
  fmt.Println(count)

  //fmt.Println(results)
  for i := 0; i < n; i++ {
    if results[i] == 0 {
      fmt.Print(i+1)
    }
  }
}


You have a permutation: an array $$$a = [a_1, a_2, \ldots, a_n]$$$ of distinct integers from $$$1$$$ to $$$n$$$. The length of the permutation $$$n$$$ is odd.You need to sort the permutation in increasing order.In one step, you can choose any prefix of the permutation with an odd length and reverse it. Formally, if $$$a = [a_1, a_2, \ldots, a_n]$$$, you can choose any odd integer $$$p$$$ between $$$1$$$ and $$$n$$$, inclusive, and set $$$a$$$ to $$$[a_p, a_{p-1}, \ldots, a_1, a_{p+1}, a_{p+2}, \ldots, a_n]$$$.Find a way to sort $$$a$$$ using no more than $$$\frac{5n}{2}$$$ reversals of the above kind, or determine that such a way doesn't exist. The number of reversals doesn't have to be minimized.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$3 \le n \le 2021$$$; $$$n$$$ is odd) — the length of the permutation. The second line contains $$$n$$$ distinct integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — the permutation itself.  It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2021$$$.

For each test case, if it's impossible to sort the given permutation in at most $$$\frac{5n}{2}$$$ reversals, print a single integer $$$-1$$$. Otherwise, print an integer $$$m$$$ ($$$0 \le m \le \frac{5n}{2}$$$), denoting the number of reversals in your sequence of steps, followed by $$$m$$$ integers $$$p_i$$$ ($$$1 \le p_i \le n$$$; $$$p_i$$$ is odd), denoting the lengths of the prefixes of $$$a$$$ to be reversed, in chronological order. Note that $$$m$$$ doesn't have to be minimized. If there are multiple answers, print any.

NoteIn the first test case, the permutation is already sorted. Any even number of reversals of the length $$$3$$$ prefix doesn't change that fact.In the second test case, after reversing the prefix of length $$$3$$$ the permutation will change to $$$[5, 4, 3, 2, 1]$$$, and then after reversing the prefix of length $$$5$$$ the permutation will change to $$$[1, 2, 3, 4, 5]$$$.In the third test case, it's impossible to sort the permutation.

package main

import (
	"fmt"
	"sort"
)

func solution() {
	var (
		n int
	)
	s := make([][]int, 2)
	fmt.Scan(&n)
	a := make([]int, n+1)
	b := make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Scan(&a[i])
		b[a[i]] = i
		s[i%2] = append(s[i%2], a[i])
	}
	for i := 0; i < 2; i++ {
		sort.Ints(s[i])
		for j := 1; j < len(s[i]); j++ {
			if (s[i][j] - s[i][j-1]) != 2 {
				fmt.Printf("-1\n")
				return
			}
		}
	}
	l := 1
	var r int
	ans := []int{}
	op := func(y int) {
		if y == 1 {
			return
		}
		ans = append(ans, y)
		l = 1
		r = y
		for l < r {
			a[l], a[r] = a[r], a[l]
			b[a[l]] = l
			b[a[r]] = r
			l++
			r--
		}
	}
	for i := n; i >= 3; i -= 2 {
		if b[i] < b[i-1] {
			op(b[i])
			op(b[i-1] - 1)
			op(b[i-1] + 1)
			op(3)
			op(i)
		} else {
			op(b[i])
			op(b[i-1] - 1)
			op(b[i-1] + 1)
			op(b[i])
			op(i)
		}
	}
	fmt.Printf("%d\n", len(ans))
	for _, val := range ans {
		fmt.Printf("%d ", val)
	}
}

func main() {
	var tests int
	fmt.Scan(&tests)
	for test := 0; test < tests; test++ {
		solution()
	}
}


Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false. Implication is written by using character '', and the arguments and the result of the implication are written as '0' (false) and '1' (true). According to the definition of the implication:   When a logical expression contains multiple implications, then when there are no brackets, it will be calculated from left to fight. For example,. When there are brackets, we first calculate the expression in brackets. For example,.For the given logical expression  determine if it is possible to place there brackets so that the value of a logical expression is false. If it is possible, your task is to find such an arrangement of brackets.

The first line contains integer n (1 ≤ n ≤ 100 000) — the number of arguments in a logical expression. The second line contains n numbers a1, a2, ..., an (), which means the values of arguments in the expression in the order they occur.

Print "NO" (without the quotes), if it is impossible to place brackets in the expression so that its value was equal to 0. Otherwise, print "YES" in the first line and the logical expression with the required arrangement of brackets in the second line. The expression should only contain characters '0', '1', '-' (character with ASCII code 45), '>' (character with ASCII code 62), '(' and ')'. Characters '-' and '>' can occur in an expression only paired like that: ("->") and represent implication. The total number of logical arguments (i.e. digits '0' and '1') in the expression must be equal to n. The order in which the digits follow in the expression from left to right must coincide with a1, a2, ..., an. The expression should be correct. More formally, a correct expression is determined as follows:   Expressions "0", "1" (without the quotes) are correct.  If v1, v2 are correct, then v1->v2 is a correct expression.  If v is a correct expression, then (v) is a correct expression.  The total number of characters in the resulting expression mustn't exceed 106. If there are multiple possible answers, you are allowed to print any of them.

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    var n int64
    if scanner.Scan() {
        n, _ = strconv.ParseInt(scanner.Text(), 10, 64)
    }

    in := make([]int64, n)
    id := int64(0)
    scanner.Split(bufio.ScanWords)
    for scanner.Scan() {
        in[id], _ = strconv.ParseInt(scanner.Text(), 10, 64)
        id++
    }

    if in[n-1] == 1 {
        fmt.Println("NO")
    } else {
        if n == 1 {
            fmt.Println("YES")
            fmt.Println(in[n-1])
        } else {
            if in[n-2] == 1 {
                fmt.Println("YES")
                for _, x := range in[:n-1] {
                    fmt.Printf("%d->", x)
                }
                fmt.Println(in[n-1])
            } else { // in[n-2] == 0 && in[n-1] == 0

                id = n - 3
                for id >= 0 && in[id] != 0 {
                    id--
                }
                if id == -1 {
                    fmt.Println("NO")

                } else {
                    fmt.Println("YES")
                    for _, x := range in[:id] {
                        fmt.Printf("%d->", x)
                    }

                    fmt.Printf("(%d->(", in[id])
                    for _, x := range in[id+1 : n-2] {
                        fmt.Printf("%d->", x)
                    }
                    fmt.Printf("%d))->", in[n-2])
                    fmt.Println(in[n-1])
                }
            }
        }
    }
}


Adilbek was assigned to a special project. For Adilbek it means that he has $$$n$$$ days to run a special program and provide its results. But there is a problem: the program needs to run for $$$d$$$ days to calculate the results.Fortunately, Adilbek can optimize the program. If he spends $$$x$$$ ($$$x$$$ is a non-negative integer) days optimizing the program, he will make the program run in $$$\left\lceil \frac{d}{x + 1} \right\rceil$$$ days ($$$\left\lceil a \right\rceil$$$ is the ceiling function: $$$\left\lceil 2.4 \right\rceil = 3$$$, $$$\left\lceil 2 \right\rceil = 2$$$). The program cannot be run and optimized simultaneously, so the total number of days he will spend is equal to $$$x + \left\lceil \frac{d}{x + 1} \right\rceil$$$.Will Adilbek be able to provide the generated results in no more than $$$n$$$ days?

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of test cases. The next $$$T$$$ lines contain test cases – one per line. Each line contains two integers $$$n$$$ and $$$d$$$ ($$$1 \le n \le 10^9$$$, $$$1 \le d \le 10^9$$$) — the number of days before the deadline and the number of days the program runs.

Print $$$T$$$ answers — one per test case. For each test case print YES (case insensitive) if Adilbek can fit in $$$n$$$ days or NO (case insensitive) otherwise.

NoteIn the first test case, Adilbek decides not to optimize the program at all, since $$$d \le n$$$.In the second test case, Adilbek can spend $$$1$$$ day optimizing the program and it will run $$$\left\lceil \frac{5}{2} \right\rceil = 3$$$ days. In total, he will spend $$$4$$$ days and will fit in the limit.In the third test case, it's impossible to fit in the limit. For example, if Adilbek will optimize the program $$$2$$$ days, it'll still work $$$\left\lceil \frac{11}{2+1} \right\rceil = 4$$$ days.

package main

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

func main() {

tc:
	for t := ReadInt(); t > 0; t-- {
		n, d := ReadInt64(), ReadInt64()

		for a := int64(0); a <= n; a++ {
			//if math.Ceil(float64(d)/float64(a))-float64(1) > float64(n) {
			if a +  (d + a) / (a+1) <= n{
				out <- "YES"
				continue tc
			}
		}
		out <- "NO"
	}
	close(out)
	outWg.Wait()
}

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

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() int64 {
	intStr := ReadString()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

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

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

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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)
	//fmt.Println("debug", t)
	for tt := int64(0); tt < t; tt++ {
		n, d := int64(0), int64(0)
		fmt.Fscanf(in, "%d %d\n", &n, &d)
		//fmt.Println("debugwtf", n, d)
		best := d
		for i := int64(1); i <= n && (i-1)*(i-1) <= d; i++ {
			cur := i + (d / (i + 1))
			if d%(i+1) != 0 {
				cur++
			}
			//fmt.Println(i, cur)
			if cur < best {
				best = cur
			}
		}
		if best > n {
			fmt.Fprintf(out, "NO\n")
		} else {
			fmt.Fprintf(out, "YES\n")
		}
	}
	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"
)

func ceil(n, m int) int {
	return (n + m - 1) / m
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	T := nextInt(sc)
	ans := make([]int, T)
	for i := 0; i < T; i++ {
		n := nextInt(sc)
		d := nextInt(sc)
		if n >= d { // no optimization needed
			ans[i] = 1
		} else {
			// x + ceil(d,x+1) <= n を満たすxがあるかどうか？
			ok, ng := 0, n
			for abs(ok-ng) > 1 {
				mid := (ok + ng) / 2
				// fmt.Printf("ok %d, ng %d, ng %d\n", ok, ng, mid)
				if mid+ceil(d, mid+1) <= n {
					// fmt.Println("found ok", mid)
					ok = mid
				} else {
					ng = mid
				}
			}
			if 0 < ok && ok < n {
				ans[i] = ok
			}
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < T; i++ {
		if ans[i] >= 1 {
			fmt.Fprintln(wtr, "YES")
		} else {
			fmt.Fprintln(wtr, "NO")
		}
	}
	wtr.Flush()
}

package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

func scanInt64() int64 {
	sc.Scan()
	a, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return a
}

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

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 {
			fmt.Fprint(wr, " ")
		}
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

var (
	T int
	n int
	d int
)

func main() {
	sc.Split(bufio.ScanWords)
	T = scanInt()
	for cas := 0; cas < T; cas++ {
		n = scanInt()
		d = scanInt()
		ans := d
		for i := 2; i <= 100000; i++ {
			tmp := d / i
			if d%i != 0 {
				tmp++
			}
			tmp += i - 1
			if tmp < ans {
				ans = tmp
			}
		}
		if ans <= n {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc_days(d, x int64) int64 {
	return x + int64(math.Ceil(float64(d)/float64(x+1)))
}

func bin_search(n, d, l, r int64) bool {
	if l > r {
		return false
	}
	mid := l + (r-l)/2
	days := calc_days(d, mid)
	if days <= n {
		return true
	}
	return bin_search(n, d, l, mid-1) || bin_search(n, d, mid+1, r)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t int
	var n, d int64
	fmt.Fscanln(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscanln(reader, &n, &d)
		if d <= n || bin_search(n, d, 1, n-1) {
			fmt.Fprintln(writer, "YES")
			continue
		}
		fmt.Fprintln(writer, "NO")
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
func work() {
	n := ReadInt()
	d := ReadInt()
	Mn := n + 1
	for L, R := 1, 1; L <= d; L = R + 1 {
		R =  d / ( d / L)
		tmp := L - 1 + d / L
		if d % L != 0 {
			tmp++
		}
		Mn = min(Mn, tmp)
	}
	if Mn > n {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}
func main() {
	for i := ReadInt() ; i > 0; i-- {
		work()
	}
	close(out)
}
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
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
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.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
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(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i<t; i++{
		var n, d int
		fmt.Scanf("%d %d\n", &n, &d)
		dSqrt := math.Sqrt(float64(d))
		if float64(n) >= math.Ceil(2*dSqrt- 1){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1288A(in io.Reader, out io.Writer) {
	var t, n, d int
o:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &d)
		s := int(math.Sqrt(float64(d)))
		for i := s - 10; i < s+10; i++ {
			if i >= 0 && i+(d-1)/(i+1)+1 <= n {
				Fprintln(out, "YES")
				continue o
			}
		}
		Fprintln(out, "NO")
	}
}

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

package main

import (
	. "fmt"
	"math"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var t, n, d int
o:
	for Scan(&t); t > 0; t-- {
		Scan(&n, &d)
		s := int(math.Sqrt(float64(d)))
		for i := s - 9; i < s+9; i++ {
			if i >= 0 && i+(d-1)/(i+1)+1 <= n {
				Println("YES")
				continue o
			}
		}
		Println("NO")
	}
}

package main

import (
	. "fmt"
	"math"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var t, n, d int
	for Scan(&t); t > 0; t-- {
		if Scan(&n, &d); n >= int(math.Ceil(2*math.Sqrt(float64(d))-1)) {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"math"
	"os"
)

func main() {
	var T int
	fmt.Fscanln(os.Stdin, &T)

	var n, d int
	var found bool
	for i := 0; i < T; i++ {
		fmt.Fscanln(os.Stdin, &n, &d)
		if n >= d {
			fmt.Println("yes")
			continue
		}
		found = false
		for x := 0; x < n; x++ {
			if x + int(math.Ceil(float64(d) / float64(x + 1))) <= n {
				found = true
				break
			}
		}
		if found {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

package main

import "fmt"

func main() {

	//get T
	var T int
	fmt.Scan(&T)

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

		// get input
		var n, d int
		fmt.Scan(&n, &d)

		ok := false
		for x := 0; x < n; x++ {

			if (x+1)*(n-x) >= d {
				ok = true
				break
			}
		}

		if ok {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

package main

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

const INFINITY = math.MaxInt32/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	for t := stdin.ReadInt(); t > 0; t-- {
		n := stdin.ReadInt64()
		d := stdin.ReadInt64()

		ok := false
		for x := int64(0); x*x <= d; x++ {
			if x+CeilDiv64(d, x+1) <= n {
				ok = true
				break
			}
		}

		if ok {
			stdout.Println("YES")
		} else {
			stdout.Println("NO")
		}
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadInt64() int64 {
	n, _ := strconv.ParseInt(s.Read(), 10, 64)
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

func (s *Stdin) ReadIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt()
	}
	return a
}

func (s *Stdin) ReadStringSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = s.Read()
	}
	return a
}

func (s *Stdin) ReadFloat64Slice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadFloat64()
	}
	return a
}

func (s *Stdin) ReadInt64Slice(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt64()
	}
	return a
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func IsPrime(x int) bool {
	if x < 2 {
		return false
	}

	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm(x, y int) int {
	return x * y / Gcd(x, y)
}

func CeilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

func LCS(s, t string) string {
	n := len(s)
	m := len(t)
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, m+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = Max(dp[i-1][j], dp[i][j-1])
			}
		}
	}

	x := n
	y := m
	u := make([]byte, dp[n][m])
	i := dp[n][m] - 1
	for x > 0 && y > 0 {
		if dp[x][y] == dp[x-1][y] {
			x--
		} else if dp[x][y] == dp[x][y-1] {
			y--
		} else {
			x--
			y--
			u[i] = s[x]
			i--
		}
	}

	return string(u)
}

// [0..n) から r個選んだ組合せを生成する。
// r < 0 の場合はすべての組合せを生成する。
func Combinations(n int, r int) [][]int {
	a := [][]int{}
	for i := uint(0); i < (1 << uint(n)); i++ {
		b := []int{}
		for j := uint(0); j < uint(n); j++ {
			if i&(uint(1)<<j) != 0 {
				b = append(b, int(j))
			}
		}

		if r < 0 || len(b) == r {
			a = append(a, b)
		}
	}
	return a
}

// [0..n)の順列を生成する。
func Permutations(n int) [][]int {
	type e struct {
		bit uint
		a   []int
	}

	q := []*e{}
	for i := 0; i < n; i++ {
		q = append(q, &e{bit: 1 << uint(i), a: []int{i}})
	}

	p := [][]int{}
	for x := 0; x < len(q); x++ {
		cur := q[x]
		if cur.bit == (1<<uint(n) - 1) {
			p = append(p, cur.a)
			continue
		}

		for i := 0; i < n; i++ {
			if cur.bit&(1<<uint(i)) != 0 {
				continue
			}

			m := len(cur.a) + 1
			b := make([]int, m)
			copy(b, cur.a)
			b[m-1] = i
			q = append(q, &e{bit: cur.bit | (1 << uint(i)), a: b})
		}
	}
	return p
}

func ReverseSlice(v interface{}) {
	if reflect.TypeOf(v).Kind() == reflect.Slice {
		slice := reflect.ValueOf(v)
		for i1, n := 0, slice.Len(); i1 < n/2; i1++ {
			i2 := n - i1 - 1
			v1 := reflect.ValueOf(slice.Index(i1).Interface())
			slice.Index(i1).Set(slice.Index(i2))
			slice.Index(i2).Set(v1)
		}
	}
}

func ReverseString(s string) string {
	t := []rune(s)
	ReverseSlice(t)
	return string(t)
}

func ToStringSlice(slice interface{}) []string {
	// 本来はerrを返却すべき。 利用する側(=自分)は引数がsliceであることを知っている。
	if reflect.TypeOf(slice).Kind() != reflect.Slice {
		panic(fmt.Sprintf("%v is not slice", slice))
	}

	src := reflect.ValueOf(slice)
	n := src.Len()
	dst := make([]string, n)
	for i := 0; i < n; i++ {
		dst[i] = fmt.Sprintf("%v", src.Index(i))
	}
	return dst
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}

func Min64(a int64, b ...int64) int64 {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max64(a int64, b ...int64) int64 {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs64(x int64) int64 {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow64(x, y int64) int64 {
	z := int64(1)
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y--
		}
	}
	return z
}

func IsPrime64(x int64) bool {
	if x < 2 {
		return false
	}

	for i := int64(2); i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm64(x, y int64) int64 {
	return x * y / Gcd64(x, y)
}

func CeilDiv64(x, y int64) int64 {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

package main

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

func main() {

tc:
	for t := ReadInt(); t > 0; t-- {
		n, d := ReadInt64(), ReadInt64()
		//if d <= n {
		//	out <- "YES"
		//	continue
		//}

		for a := n-2; a > 0; a-- {
			if math.Ceil(float64(d)/float64(a))-float64(1) > float64(n) {
				out <- "NO"
				continue tc
			}
		}
		out <- "YES"
	}
	close(out)
	outWg.Wait()
}

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

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() int64 {
	intStr := ReadString()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

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

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

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

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)
	//fmt.Println("debug", t)
	for tt := int64(0); tt < t; tt++ {
		n, d := int64(0), int64(0)
		fmt.Fscanf(in, "%d %d\n", &n, &d)
		//fmt.Println("debugwtf", n, d)
		best := d
		for i := int64(1); i < n; i++ {
			cur := i + (d / (i + 1))
			if d%(i+1) != 0 {
				cur++
			}
			//fmt.Println(i, cur)
			if cur < best {
				best = cur
			} else {
				break
			}
		}
		if best > n {
			fmt.Fprintf(out, "NO\n")
		} else {
			fmt.Fprintf(out, "YES\n")
		}
	}
	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"
)

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, d := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &d)
		//fmt.Println(n, d)
		best := d
		for i := 0; i < n; i++ {
			cur := i + (d / (i + 1))
			if d%(i+1) != 0 {
				cur++
			}
			//fmt.Println(i, cur)
			if cur < best {
				best = cur
			} else {
				break
			}
		}
		if best > n {
			fmt.Fprintf(out, "NO\n")
		} else {
			fmt.Fprintf(out, "YES\n")
		}
	}
	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"
)

func ceil(n, m int) int {
	return (n + m - 1) / m
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	T := nextInt(sc)
	ans := make([]int, T)
	for i := 0; i < T; i++ {
		n := nextInt(sc)
		d := nextInt(sc)
		if n >= d { // no optimization needed
			ans[i] = 1
		} else {
			// x + ceil(d,x+1) <= n を満たすxがあるかどうか？
			left, right := 1, int(1e9)+1
			ok := false
			for right-left > 1 {
				mid := (right + left) / 2
				// fmt.Printf("left %d, mid %d, right %d\n", left, mid, right)
				if ceil(d, mid+1) <= n-mid {
					// fmt.Println("found ok", mid)
					ok = true
					left = mid
				} else {
					right = mid
				}
			}
			if ok {
				ans[i] = left
			}
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < T; i++ {
		if ans[i] >= 1 {
			fmt.Fprintln(wtr, "YES")
		} else {
			fmt.Fprintln(wtr, "NO")
		}
	}
	wtr.Flush()
}

package main

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

func ceil(n, m int) int {
	return (n + m - 1) / m
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	T := nextInt(sc)
	ans := make([]int, T)
	for i := 0; i < T; i++ {
		n := nextInt(sc)
		d := nextInt(sc)
		if n >= d { // no optimization needed
			ans[i] = 1
		} else {
			// x + ceil(d,x+1) <= n を満たすxがあるかどうか？
			left, right := 0, int(1e9)+1
			ok := false
			for right-left > 1 {
				mid := (right + left) / 2
				if ceil(d, mid+1) <= n-mid {
					ok = true
					left = mid
				} else {
					right = mid
				}
			}
			if ok {
				ans[i] = left
			}
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < T; i++ {
		if ans[i] >= 1 {
			fmt.Fprintln(wtr, "YES")
		} else {
			fmt.Fprintln(wtr, "NO")
		}
	}
	wtr.Flush()
}

package main

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

func calc_days(d, x int64) int64 {
	return x + int64(math.Ceil(float64(d)/float64(x+1)))
}

func bin_search(n, d, l, r int64) bool {
	if l > r {
		return false
	}
	mid := l + (r-l)/2
	days := calc_days(d, mid)
	if days <= n {
		return true
	}
	return bin_search(n, d, l, mid-1)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t int
	var n, d int64
	fmt.Fscanln(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscanln(reader, &n, &d)
		if d <= n || bin_search(n, d, 1, d-1) {
			fmt.Fprintln(writer, "YES")
			continue
		}
		fmt.Fprintln(writer, "NO")
	}
}

package main

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

const limit = 1000000000

func calc_days(d, x int64) int64 {
	return x + int64(math.Ceil(float64(d)/float64(x+1)))
}

func bin_search(n, d, l, r int64) bool {
	if l > r {
		return false
	}
	mid := l + (r-l)/2
	days := calc_days(d, mid)
	if days <= n {
		return true
	}
	return bin_search(n, d, l, mid-1)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t int
	var n, d int64
	fmt.Fscanln(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscanln(reader, &n, &d)
		if d <= n || bin_search(n, d, 1, limit) {
			fmt.Fprintln(writer, "YES")
			continue
		}
		fmt.Fprintln(writer, "NO")
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i<t; i++{
		var n, d int
		dSqrt := math.Sqrt(float64(d))
		if float64(n) >= math.Ceil(2*dSqrt - 1){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i<t; i++{
		var n, d int
		fmt.Scanf("%d %d", &n, &d)
		dSqrt := math.Sqrt(float64(d))
		if float64(n) >= math.Ceil(2*dSqrt- 1){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import (
	. "fmt"
	"math"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var t, n, d int
	for Scan(&t); t > 0; t-- {
		if Scan(&n, &d); n >= int(2*math.Sqrt(float64(d))-1) {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main

import "fmt"

func main() {

	// get input
	var inp int
	fmt.Scan(&inp)

	if inp%2 == 0 && inp > 3 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

const INFINITY = math.MaxInt32/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	for t := stdin.ReadInt(); t > 0; t-- {
		n := stdin.ReadInt64()
		d := stdin.ReadInt64()

		x := (d - 1) / 2
		if x+CeilDiv64(d, x+1) <= n {
			stdout.Println("YES")
		} else {
			stdout.Println("NO")
		}
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadInt64() int64 {
	n, _ := strconv.ParseInt(s.Read(), 10, 64)
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

func (s *Stdin) ReadIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt()
	}
	return a
}

func (s *Stdin) ReadStringSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = s.Read()
	}
	return a
}

func (s *Stdin) ReadFloat64Slice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadFloat64()
	}
	return a
}

func (s *Stdin) ReadInt64Slice(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt64()
	}
	return a
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func IsPrime(x int) bool {
	if x < 2 {
		return false
	}

	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm(x, y int) int {
	return x * y / Gcd(x, y)
}

func CeilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

func LCS(s, t string) string {
	n := len(s)
	m := len(t)
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, m+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = Max(dp[i-1][j], dp[i][j-1])
			}
		}
	}

	x := n
	y := m
	u := make([]byte, dp[n][m])
	i := dp[n][m] - 1
	for x > 0 && y > 0 {
		if dp[x][y] == dp[x-1][y] {
			x--
		} else if dp[x][y] == dp[x][y-1] {
			y--
		} else {
			x--
			y--
			u[i] = s[x]
			i--
		}
	}

	return string(u)
}

// [0..n) から r個選んだ組合せを生成する。
// r < 0 の場合はすべての組合せを生成する。
func Combinations(n int, r int) [][]int {
	a := [][]int{}
	for i := uint(0); i < (1 << uint(n)); i++ {
		b := []int{}
		for j := uint(0); j < uint(n); j++ {
			if i&(uint(1)<<j) != 0 {
				b = append(b, int(j))
			}
		}

		if r < 0 || len(b) == r {
			a = append(a, b)
		}
	}
	return a
}

// [0..n)の順列を生成する。
func Permutations(n int) [][]int {
	type e struct {
		bit uint
		a   []int
	}

	q := []*e{}
	for i := 0; i < n; i++ {
		q = append(q, &e{bit: 1 << uint(i), a: []int{i}})
	}

	p := [][]int{}
	for x := 0; x < len(q); x++ {
		cur := q[x]
		if cur.bit == (1<<uint(n) - 1) {
			p = append(p, cur.a)
			continue
		}

		for i := 0; i < n; i++ {
			if cur.bit&(1<<uint(i)) != 0 {
				continue
			}

			m := len(cur.a) + 1
			b := make([]int, m)
			copy(b, cur.a)
			b[m-1] = i
			q = append(q, &e{bit: cur.bit | (1 << uint(i)), a: b})
		}
	}
	return p
}

func ReverseSlice(v interface{}) {
	if reflect.TypeOf(v).Kind() == reflect.Slice {
		slice := reflect.ValueOf(v)
		for i1, n := 0, slice.Len(); i1 < n/2; i1++ {
			i2 := n - i1 - 1
			v1 := reflect.ValueOf(slice.Index(i1).Interface())
			slice.Index(i1).Set(slice.Index(i2))
			slice.Index(i2).Set(v1)
		}
	}
}

func ReverseString(s string) string {
	t := []rune(s)
	ReverseSlice(t)
	return string(t)
}

func ToStringSlice(slice interface{}) []string {
	// 本来はerrを返却すべき。 利用する側(=自分)は引数がsliceであることを知っている。
	if reflect.TypeOf(slice).Kind() != reflect.Slice {
		panic(fmt.Sprintf("%v is not slice", slice))
	}

	src := reflect.ValueOf(slice)
	n := src.Len()
	dst := make([]string, n)
	for i := 0; i < n; i++ {
		dst[i] = fmt.Sprintf("%v", src.Index(i))
	}
	return dst
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}

func Min64(a int64, b ...int64) int64 {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max64(a int64, b ...int64) int64 {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs64(x int64) int64 {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow64(x, y int64) int64 {
	z := int64(1)
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y--
		}
	}
	return z
}

func IsPrime64(x int64) bool {
	if x < 2 {
		return false
	}

	for i := int64(2); i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm64(x, y int64) int64 {
	return x * y / Gcd64(x, y)
}

func CeilDiv64(x, y int64) int64 {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}


Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.The killer starts with two potential victims on his first day, selects one of these two, kills selected victim and replaces him with a new person. He repeats this procedure each day. This way, each day he has two potential victims to choose from. Sherlock knows the initial two potential victims. Also, he knows the murder that happened on a particular day and the new person who replaced this victim.You need to help him get all the pairs of potential victims at each day so that Sherlock can observe some pattern.

First line of input contains two names (length of each of them doesn't exceed 10), the two initials potential victims. Next line contains integer n (1 ≤ n ≤ 1000), the number of days. Next n lines contains two names (length of each of them doesn't exceed 10), first being the person murdered on this day and the second being the one who replaced that person. The input format is consistent, that is, a person murdered is guaranteed to be from the two potential victims at that time. Also, all the names are guaranteed to be distinct and consists of lowercase English letters.

Output n + 1 lines, the i-th line should contain the two persons from which the killer selects for the i-th murder. The (n + 1)-th line should contain the two persons from which the next victim is selected. In each line, the two names can be printed in any order.

ross rachel
4
ross joey
rachel phoebe
phoebe monica
monica chandler

ross rachel
joey rachel
joey phoebe
joey monica
joey chandler

NoteIn first example, the killer starts with ross and rachel.   After day 1, ross is killed and joey appears.  After day 2, rachel is killed and phoebe appears.  After day 3, phoebe is killed and monica appears.  After day 4, monica is killed and chandler appears.

package main

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

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

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

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

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

func main() {
	defer w.Flush()
	var n int
	var a, b string
	for I(&a, &b, &n) == nil {
		solve(a, b, n)
	}
}

func solve(a, b string, n int) {
	O(a, " ", b, "\n")
	for i := 0; i < n; i++ {
		var c, d string
		I(&c, &d)
		if a == c {
			a = d
		} else {
			b = d
		}
		O(a, " ", b, "\n")
	}
}

package main

import (
	"fmt"
)

func determine_victims() {
	var name1, name2, name3, name4 string
	var n int

	fmt.Scanln(&name1, &name2)
	fmt.Scanln(&n)

	fmt.Println(name1, name2)

	for i := 0; i<n; i++ {
		fmt.Scanln(&name3, &name4)
		if name1 == name3 {
			name1 = name4
		} else {
			name2 = name4
		}
		fmt.Println(name1, name2)
	}
}

func main() {
	determine_victims()
}

package main

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

func main() {
	var n int
	var potential []string

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)

	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		t := strings.Split(re.ReplaceAllString(s, ""), " ")
		if len(t) != 2 {
			return
		}
		potential = t
	}

	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		u := re.ReplaceAllString(s, "")
		n, err = strconv.Atoi(u)
		if err != nil {
			return
		}
	}
	fmt.Printf("%s %s\n", potential[0], potential[1])

	for i := 0; i < n; i++ {
		if _in, err := reader.ReadString('\n'); err != nil {
			if err == io.EOF {
				break
			} else {
				return
			}
		} else {
			ab := strings.Split(re.ReplaceAllString(_in, ""), " ")
			if len(ab) != 2 {
				return
			}
			if potential[0] == ab[0] {
				potential[0] = ab[1]
			} else if potential[1] == ab[0] {
				potential[1] = ab[1]
			}
			fmt.Printf("%s %s\n", potential[0], potential[1])
		}
	}
}

package main

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

func solve() {
	mm := make(map[string]bool)
	mm[readString()] = true
	mm[readString()] = true
	printPeople(mm)
	n := readInt()
	for i := 0; i < n; i++ {
		p1 := readString()
		delete(mm, p1)
		mm[readString()] = true
		printPeople(mm)
	}
}

func printPeople(mm map[string]bool) {
	res := ""
	for k, _ := range mm {
		if res == "" {
			res = k
		} else {
			res += " " + k
		}
	}
	fmt.Println(res)
}

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

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

// 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
}

package main

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

func main() {
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextString()
	b := cin.nextString()
	fmt.Printf("%s %s\n", a, b)
	n := cin.nextInt()
	for i := 0; i < n; i++ {
		c := cin.nextString()
		d := cin.nextString()
		if c == a || c == b {
			if c == a {
				a = d
			} else {
				b = d
			}
		} else if d == a || d == b {
			if d == a {
				a = c
			} else {
				b = c
			}
		} else {
			panic("bad input")
		}
		fmt.Printf("%s %s\n", a, b)
	}
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c-'0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c-'0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}

func isSpace(c byte) bool {
	return c < 32 || c == ' ' || c == '\n' || c == '\t'
}

func (p *ParserReader) nextString() string {
	for isSpace(p.c) && p.err == nil {
		p.next()
	}
	r := make([]byte, 0, 1)
	for !isSpace(p.c) && p.err == nil {
		r = append(r, p.c)
		p.next()
	}
	return string(r)
}

package main

import (
	"fmt"
)

func main() {
	var arr, arrTmp [2]string
	var testcount int
	fmt.Scanf("%s %s\n", &arr[0], &arr[1])
	fmt.Scanf("%d\n", &testcount)
	for i := 0; i < testcount; i++ {
		fmt.Printf("%s %s\n", arr[0], arr[1])
		fmt.Scanf("%s %s\n", &arrTmp[0], &arrTmp[1])
		if arrTmp[0] == arr[0] {
			arr[0] = arrTmp[1]
		} else {
			arr[1] = arrTmp[1]
		}
	}
	fmt.Printf("%s %s\n", arr[0], arr[1])
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	line, _ := reader.ReadString('\n')
	arr := strings.Split(strings.TrimSpace(line), " ")
	line, _ = reader.ReadString('\n')
	testcount, _ := strconv.Atoi(strings.TrimSpace(line))
	for i := 0; i < testcount; i++ {
		writer.WriteString(arr[0] + " " + arr[1] + "\n")
		line, _ = reader.ReadString('\n')
		tmp := strings.Split(strings.TrimSpace(line), " ")
		if tmp[0] == arr[0] {
			arr[0] = tmp[1]
		} else {
			arr[1] = tmp[1]
		}
	}
	writer.WriteString(arr[0] + " " + arr[1] + "\n")
	writer.Flush()
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	arr := strings.Split(strings.TrimSpace(line), " ")
	line, _ = reader.ReadString('\n')
	testcount, _ := strconv.Atoi(strings.TrimSpace(line))
	for i := 0; i < testcount; i++ {
		fmt.Printf("%s %s\n", arr[0], arr[1])
		line, _ = reader.ReadString('\n')
		tmp := strings.Split(strings.TrimSpace(line), " ")
		if tmp[0] == arr[0] {
			arr[0] = tmp[1]
		} else {
			arr[1] = tmp[1]
		}
	}
	fmt.Printf("%s %s\n", arr[0], arr[1])
}

package main

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

func main() {
	sc := NewScanner()
	A, B := sc.Next(), sc.Next()
	N := sc.NextInt()
	fmt.Println(A, B)
	for i := 0; i < N; i++ {
		C, D := sc.Next(), sc.Next()
		if A == C {
			A = D
		} else {
			B = D
		}
		fmt.Println(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 (
	"bufio"
	"io"
	"os"
	"fmt"
)

func main() {
	f, _ := os.Open("a.in")
	cin := NewParser(bufio.NewReaderSize(f, 1<<16))
	// cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextString()
	b := cin.nextString()
	fmt.Printf("%s %s\n", a, b)
	n := cin.nextInt()
	for i := 0; i < n; i++ {
		c := cin.nextString()
		d := cin.nextString()
		if c == a || c == b {
			if c == a {
				a = d
			} else {
				b = d
			}
		} else if d == a || d == b {
			if d == a {
				a = c
			} else {
				b = c
			}
		} else {
			panic("bad input")
		}
		fmt.Printf("%s %s\n", a, b)
	}
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c-'0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c-'0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}

func isSpace(c byte) bool {
	return c < 32 || c == ' ' || c == '\n' || c == '\t'
}

func (p *ParserReader) nextString() string {
	for isSpace(p.c) && p.err == nil {
		p.next()
	}
	r := make([]byte, 0, 1)
	for !isSpace(p.c) && p.err == nil {
		r = append(r, p.c)
		p.next()
	}
	return string(r)
}


You are given n distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothing.You consider several coinciding straight lines as a single one. How many distinct pictures you can get? Print the answer modulo 109 + 7.

The first line contains single integer n (1 ≤ n ≤ 105) — the number of points. n lines follow. The (i + 1)-th of these lines contains two integers xi, yi ( - 109 ≤ xi, yi ≤ 109) — coordinates of the i-th point. It is guaranteed that all points are distinct.

Print the number of possible distinct pictures modulo 109 + 7.

NoteIn the first example there are two vertical and two horizontal lines passing through the points. You can get pictures with any subset of these lines. For example, you can get the picture containing all four lines in two ways (each segment represents a line containing it). The first way:      The second way:      In the second example you can work with two points independently. The number of pictures is 32 = 9.

package main

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

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

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

func toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var points [2][]pair
var pts [100005]pair
var g [100005][]int
var used [100005]bool
var diff_x,diff_y []int
var cycle_found bool
var MD int64 = 1000000007
var used_x,used_y map[int]bool
var n,x,y int

func deg(d int) int64 {
	if d == 0 {
		return 1
	}
	t := deg(d / 2)
	t *= t
	t %= MD
	if d % 2 == 1 {
		t = t * 2 % MD
	}
	return t
}

func dfs(v,p int) {
	used[v] = true
	if !used_x[pts[v].first] {
		used_x[pts[v].first] = true
		diff_x = append(diff_x, pts[v].first)
	}
	if !used_y[pts[v].second] {
		used_y[pts[v].second] = true
		diff_y = append(diff_y, pts[v].second)
	}
	for i:= range g[v] {
		to := g[v][i]
		if to == p {
			continue
		}
		if used[to] {
			cycle_found = true
			continue
		}
		dfs(to,v)
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d\n", &n)
	mp := make(map[pair]int)
	used_x = make(map[int]bool)
	used_y = make(map[int]bool)
	for i:=1;i<=n;i++ {
		fmt.Fscanf(in, "%d %d\n",&x,&y)
		mp[pair{x,y}] = i
		pts[i] = pair{x,y}
		points[0] = append(points[0], pair{x,y})
		points[1] = append(points[1], pair{y,x})
	}
	sort.Sort(pairs(points[0]))
	sort.Sort(pairs(points[1]))
	for i:= range points[0] {
		if i > 0 {
			if points[0][i].first == points[0][i - 1].first {
				x := mp[points[0][i]]
				y := mp[points[0][i - 1]]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	for i:= range points[1] {
		if i > 0 {
			if points[1][i].first == points[1][i - 1].first {
				x := mp[pair{points[1][i].second, points[1][i].first}]
				y := mp[pair{points[1][i - 1].second, points[1][i - 1].first}]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	var ans int64
	ans = 1

	for i:= 1;i<= n;i++ {
		if !used[i] {
			cycle_found = false
			for j:= range diff_x {
				used_x[diff_x[j]] = false
			}
			for j:= range diff_y {
				used_y[diff_y[j]] = false
			}
			diff_x = nil
			diff_y = nil
			dfs(i,i)
			//fmt.Println(len(diff_x),len(diff_y))
			res := deg(len(diff_x) + len(diff_y))
			if !cycle_found {
				res--
			}
			if res < 0 {
				res += MD
			}
			ans = ans * res % MD
		}
	}
	fmt.Println(ans)
}

package main

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

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

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

func toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var points [2][]pair
var g [100005][]int
var used,used_x,used_y [100005]bool
var diff_x,diff_y []int
var cycle_found bool
var MD int64 = 1000000007

func deg(d int) int64 {
	if d == 0 {
		return 1
	}
	t := deg(d / 2)
	t *= t
	t %= MD
	if d % 2 == 1 {
		t = t * 2 % MD
	}
	return t
}

func dfs(v,p int) {
	used[v] = true
	if !used_x[points[0][v-1].first] {
		used_x[points[0][v-1].first] = true
		diff_x = append(diff_x, points[0][v-1].first)
	}
	if !used_y[points[0][v-1].second] {
		used_y[points[0][v-1].second] = true
		diff_y = append(diff_y, points[0][v-1].second)
	}
	for i:= range g[v] {
		to := g[v][i]
		if to == p {
			continue
		}
		if used[to] {
			cycle_found = true
			continue
		}
		dfs(to,v)
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n := toInt(scanner.Bytes())
	mp := make(map[pair]int)
	for i:=1;i<=n;i++ {
		scanner.Scan()
		x := toInt(scanner.Bytes())
		scanner.Scan()
		y := toInt(scanner.Bytes())
		mp[pair{x,y}] = i
		points[0] = append(points[0], pair{x,y})
		points[1] = append(points[1], pair{y,x})
	}
	sort.Sort(pairs(points[0]))
	sort.Sort(pairs(points[1]))
	for i:= range points[0] {
		if i > 0 {
			if points[0][i].first == points[0][i - 1].first {
				x := mp[points[0][i]]
				y := mp[points[0][i - 1]]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	for i:= range points[1] {
		if i > 0 {
			if points[1][i].first == points[1][i - 1].first {
				x := mp[pair{points[1][i].second, points[1][i].first}]
				y := mp[pair{points[1][i - 1].second, points[1][i - 1].first}]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	var ans int64
	ans = 1

	for i:= 1;i<= n;i++ {
		if !used[i] {
			cycle_found = false
			for j:= range diff_x {
				used_x[diff_x[j]] = false
			}
			for j:= range diff_y {
				used_y[diff_y[j]] = false
			}
			diff_x = nil
			diff_y = nil
			dfs(i,i)
			res := deg(len(diff_x) + len(diff_y))
			fmt.Println(res)
			if !cycle_found {
				res--
			}
			if res < 0 {
				res += MD
			}
			ans = ans * res % MD
		}
	}
	fmt.Println(ans)
}

package main

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

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

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

func toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var points [2][]pair
var g [100005][]int
var used [100005]bool
var diff_x,diff_y []int
var cycle_found bool
var MD int64 = 1000000007
var used_x,used_y map[int]bool

func deg(d int) int64 {
	if d == 0 {
		return 1
	}
	t := deg(d / 2)
	t *= t
	t %= MD
	if d % 2 == 1 {
		t = t * 2 % MD
	}
	return t
}

func dfs(v,p int) {
	used[v] = true
	if !used_x[points[0][v-1].first] {
		used_x[points[0][v-1].first] = true
		diff_x = append(diff_x, points[0][v-1].first)
	}
	if !used_y[points[0][v-1].second] {
		used_y[points[0][v-1].second] = true
		diff_y = append(diff_y, points[0][v-1].second)
	}
	for i:= range g[v] {
		to := g[v][i]
		if to == p {
			continue
		}
		if used[to] {
			cycle_found = true
			continue
		}
		dfs(to,v)
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n := toInt(scanner.Bytes())
	mp := make(map[pair]int)
	used_x = make(map[int]bool)
	used_y = make(map[int]bool)
	for i:=1;i<=n;i++ {
		scanner.Scan()
		x := toInt(scanner.Bytes())
		scanner.Scan()
		y := toInt(scanner.Bytes())
		mp[pair{x,y}] = i
		points[0] = append(points[0], pair{x,y})
		points[1] = append(points[1], pair{y,x})
	}
	sort.Sort(pairs(points[0]))
	sort.Sort(pairs(points[1]))
	for i:= range points[0] {
		if i > 0 {
			if points[0][i].first == points[0][i - 1].first {
				x := mp[points[0][i]]
				y := mp[points[0][i - 1]]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	for i:= range points[1] {
		if i > 0 {
			if points[1][i].first == points[1][i - 1].first {
				x := mp[pair{points[1][i].second, points[1][i].first}]
				y := mp[pair{points[1][i - 1].second, points[1][i - 1].first}]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	var ans int64
	ans = 1

	for i:= 1;i<= n;i++ {
		if !used[i] {
			cycle_found = false
			for j:= range diff_x {
				used_x[diff_x[j]] = false
			}
			for j:= range diff_y {
				used_y[diff_y[j]] = false
			}
			diff_x = nil
			diff_y = nil
			dfs(i,i)
			res := deg(len(diff_x) + len(diff_y))
			//fmt.Println(res)
			if !cycle_found {
				res--
			}
			if res < 0 {
				res += MD
			}
			ans = ans * res % MD
		}
	}
	fmt.Println(ans)
}

package main

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

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

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

func toInt(buf []byte) (o int) {
    for _, v := range buf {
        o = o*10 + int(v-'0')
    }
    return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var points [2][]pair
var pts [100005]pair
var g [100005][]int
var used [100005]bool
var diff_x,diff_y []int
var cycle_found bool
var MD int64 = 1000000007
var used_x,used_y map[int]bool

func deg(d int) int64 {
	if d == 0 {
		return 1
	}
	t := deg(d / 2)
	t *= t
	t %= MD
	if d % 2 == 1 {
		t = t * 2 % MD
	}
	return t
}

func dfs(v,p int) {
	used[v] = true
	if !used_x[pts[v].first] {
		used_x[pts[v].first] = true
		diff_x = append(diff_x, pts[v].first)
	}
	if !used_y[pts[v].second] {
		used_y[pts[v].second] = true
		diff_y = append(diff_y, pts[v].second)
	}
	for i:= range g[v] {
		to := g[v][i]
		if to == p {
			continue
		}
		if used[to] {
			cycle_found = true
			continue
		}
		dfs(to,v)
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n := toInt(scanner.Bytes())
	mp := make(map[pair]int)
	used_x = make(map[int]bool)
	used_y = make(map[int]bool)
	for i:=1;i<=n;i++ {
		scanner.Scan()
		x := toInt(scanner.Bytes())
		scanner.Scan()
		y := toInt(scanner.Bytes())
		mp[pair{x,y}] = i
		pts[i] = pair{x,y}
		points[0] = append(points[0], pair{x,y})
		points[1] = append(points[1], pair{y,x})
	}
	sort.Sort(pairs(points[0]))
	sort.Sort(pairs(points[1]))
	for i:= range points[0] {
		if i > 0 {
			if points[0][i].first == points[0][i - 1].first {
				x := mp[points[0][i]]
				y := mp[points[0][i - 1]]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	for i:= range points[1] {
		if i > 0 {
			if points[1][i].first == points[1][i - 1].first {
				x := mp[pair{points[1][i].second, points[1][i].first}]
				y := mp[pair{points[1][i - 1].second, points[1][i - 1].first}]
				g[x] = append(g[x], y)
				g[y] = append(g[y], x)
				//fmt.Println(">>",x,y)
			}
		}
	}

	var ans int64
	ans = 1

	for i:= 1;i<= n;i++ {
		if !used[i] {
			cycle_found = false
			for j:= range diff_x {
				used_x[diff_x[j]] = false
			}
			for j:= range diff_y {
				used_y[diff_y[j]] = false
			}
			diff_x = nil
			diff_y = nil
			dfs(i,i)
			//fmt.Println(len(diff_x),len(diff_y))
			res := deg(len(diff_x) + len(diff_y))
			if !cycle_found {
				res--
			}
			if res < 0 {
				res += MD
			}
			ans = ans * res % MD
		}
	}
	fmt.Println(ans)
}


You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.There are $$$n$$$ doors, the $$$i$$$-th door initially has durability equal to $$$a_i$$$.During your move you can try to break one of the doors. If you choose door $$$i$$$ and its current durability is $$$b_i$$$ then you reduce its durability to $$$max(0, b_i - x)$$$ (the value $$$x$$$ is given).During Slavik's move he tries to repair one of the doors. If he chooses door $$$i$$$ and its current durability is $$$b_i$$$ then he increases its durability to $$$b_i + y$$$ (the value $$$y$$$ is given). Slavik cannot repair doors with current durability equal to $$$0$$$.The game lasts $$$10^{100}$$$ turns. If some player cannot make his move then he has to skip it.Your goal is to maximize the number of doors with durability equal to $$$0$$$ at the end of the game. You can assume that Slavik wants to minimize the number of such doors. What is the number of such doors in the end if you both play optimally?

The first line of the input contains three integers $$$n$$$, $$$x$$$ and $$$y$$$ ($$$1 \le n \le 100$$$, $$$1 \le x, y \le 10^5$$$) — the number of doors, value $$$x$$$ and value $$$y$$$, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^5$$$), where $$$a_i$$$ is the initial durability of the $$$i$$$-th door.

Print one integer — the number of doors with durability equal to $$$0$$$ at the end of the game, if you and Slavik both play optimally.

NoteClarifications about the optimal strategy will be ignored.

package main

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n ,x,y int
	fmt.Fscanf(buf, "%d %d %d\n", &n,&x,&y)
	var cnt int=0
	for i:= 0;i < n;i++{
		var v int
		fmt.Fscanf(buf, "%d", &v)
		if v <= x{
			cnt++
		}
	}
	if x > y{
		fmt.Printf("%d\n", n)
	}else if x == y{
		fmt.Printf("%d\n", (cnt+1)/2)
	}else{
		fmt.Printf("%d\n", (cnt+1)/2)
	}

}

package main

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

func main() {
	start := time.Now()
	defer func() {
		run := time.Since(start)
		_ = run
		// fmt.Println("Run in", run)
	}()

	var stdin *bufio.Reader
	// LOCAL
	f, _ := os.Open("input.txt")
	stdin = bufio.NewReader(f)

	// ONLINE JUDGE
	stdin = bufio.NewReader(os.Stdin)

	var n, x, y int
	fmt.Fscan(stdin, &n, &x, &y)

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

	if x > y {
		fmt.Println(n)
	} else {
		fmt.Println((cnt + 1) / 2)
	}
}

package main

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

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

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

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

    n := ReadInt()
    x := ReadInt()
    y := ReadInt()

    v := make([]int, n)

    for i := 0; i < n; i++ {
    	v[i] = ReadInt()
    }

    if x > y {
    	writer.WriteString(strconv.Itoa(n))
    	return
    }

    resp := 0

    for i := 0; i < n; i++ {
    	if v[i] <= x {
    		resp++
    	}
    }

    if resp % 2 != 0 {
    	resp++
    }

	writer.WriteString(strconv.Itoa(resp/2))
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

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

func scanBytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func scanInt64() int64 {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v
}

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

func scanInts(n int) []int {
	l := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.Atoi(scanner.Text())
	}

	return l
}

func scanInts64(n int64) []int64 {
	l := make([]int64, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}

	return l
}

func scanBool() bool {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v == 1
}

func scanBools(n int64) []bool {
	l := make([]bool, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		l[i] = v == 1
	}

	return l
}

func scanUint64() uint64 {
	scanner.Scan()
	v, _ := strconv.ParseUint(scanner.Text(), 10, 64)
	return v
}

type ByAge []uint64

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

func main() {
	n, x, y := scanInt(), scanInt(), scanInt()

	a := scanInts(n)

	if x > y {
		fmt.Println(n)
		return
	}

	cnt := 0
	for i := 0; i < n; i++ {
		if a[i] <= x {
			cnt++
		}
	}

	cnt = int(math.Ceil(float64(cnt) / 2.0))
	fmt.Println(cnt)
}

func skipZero(a []uint64) []uint64 {
	for len(a) > 0 && a[0] == 0 {
		a = a[1:]
	}

	return a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}

	return -a
}

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

	return b
}